It seems that in my time away from C++, I've forgotten something that I should still know.
I have this class:
And I want to use it as a member of another class, calling the constructor for cIPAddress from within the constructor for the other class:Code:class cIPAddress { public: cIPAddress(string IPAddress) { IP=IPAddress; } private: string IP; };
Obviously, the code in the constructor cOtherClass is not the way to do it; what is?Code:class cOtherClass { public: cIPAddress ipaddress; cOtherClass(string ip){ipaddress(ip);} };



LinkBack URL
About LinkBacks


