Reputation: 2558
I have read the other threads regarding this same problem but I still don't know why I am getting the following error: undefinded reference to
and lists every method in the outer class.
class ClientConnection
{
public:
class Connector
{
public:
Connector(ClientConnection&);
~Connector();
void Connect(unsigned int usleep);
void Stop();
bool isConnected();
private:
void attempt();
ClientConnection& m_client;
unsigned int m_usleep;
bool m_stopRequest;
bool m_isBusy;
boost::shared_ptr<boost::thread> m_thread;
};
Connector* Connector();
bool connect();
bool isConnected();
private:
friend class Connector;
};
I have a reference to the outer class. The Connector method news up a Connector object and passes it a references to itself. But everywhere in code where I get an undefined reference to ClientConnection::connect
and undefined reference to ClientConnection::isConnected
.
I am completely stuck.
ALSO - when I use Connector() to new up an object, ClientConnection::Connector* connector = client.Connector();
where client is an solid object of ClientConnection, I get invalid use of non-static member function ‘ClientConnection::Connector* ClientConnection::Connector()’
Upvotes: 1
Views: 1307
Reputation: 39294
A few things to consider:
Connector* Connector();
- what are you trying to do here? If you're trying to declare a pointer to a connector, do Connector* ptr_connector;
or something. You're basically invoking a constructor, declaring a pointer, and giving neither a variable name - it's crazy!
Did you actually implement the functions were seeing in the nested class, if not that's where your problem is! Also, did you implement them correctly for a nested class? The syntax is a little different if you're not implementing them inline in the class.
ClientConnection::Connector* connector = client.Connector();
- This doesn't work either. you declared an explicit constructor in your class requiring a client connection object. But here, you're trying to create a connector without passing any client object. You don't have a constructor for Connector taking no parameters.
Upvotes: 2