How can i initialize a class object from within another class object.
class Dummy {
public:
Dummy() {}
};
class Server {
public:
string ip;
string port;
Dummy dummy; // <-- declare an object from within another object.
public:
Server(string port__, string ip__, Dummy dummy__) {
port = port__;
ip = ip__;
dummy = dummy__;
}
void some_func() {
// use dummy from here.
dummy.hello_world();
}
}
And what i want to do is use object Dummy throughout the object Server.