From this day onwards, I will start to learn C Design pattern. & I will write down my comprehensions and feelings. (For the purpose of self-examination, and communicating with newbies as me.) (Adapterd from lxgljj's article in JAVA.) #include
class PostedBook {public: PostedBook (const string & rhs) {this-> m_StringNO_ = rhs;} PostedBook (const PostedBook & rhs) {this-> m_StringNO_ = rhs.m_StringNO_;} const PostedBook & operator = (const PostedBook & rhs) {this-> M_StringNO_ = rhs.m_stringno_; return * this;} String getphonenofromBook () {return (m_stringno_);} private: string m_stringno_;};
Class TellFriend {public: void tellsth () {cout << "Azure's Phone number:";}
class TellFriendPhoneNo: public TellFriend {public: TellFriendPhoneNo (const PostedBook & pb): m_PostedBook_ (pb) {// Nothing needed to be done} void TellPhoneNumber () {cout << m_PostedBook_.GetPhoneNoFromBook () << endl;} private:. PostedBook m_postedbook_;
INT main () {PostedBook PB ("13973284801"); TellFriendphoneno GP (PB); gp.tellsth (); gp.tellphonenumber ();
Return (1);