I'm writing a server that will run in a separate thread. Since I'm using a Thread class, the server is written as a class by itself. However I need for the server to access some of the data that is in the main class.
So I have instantiated the class like so:
ServerThread serv;
in the class definition.
And I thought maybe I'd just write a method of that class I could call to save a pointer to my object, like:
serv.savePontr(this);
However when I attempt to do this I can't seem to get around the catch 22 where I have to include the header from this class in the server code and of course when it sees the ServerThread serv; it isn't defined just yet.
So the question is what's the best way of letting the server get data from the class that instantiated it. I considered a callback, but I have yet to see an example that I could understand well enough to implement.
Thanks,
Jim.
So I have instantiated the class like so:
ServerThread serv;
in the class definition.
And I thought maybe I'd just write a method of that class I could call to save a pointer to my object, like:
serv.savePontr(this);
However when I attempt to do this I can't seem to get around the catch 22 where I have to include the header from this class in the server code and of course when it sees the ServerThread serv; it isn't defined just yet.
So the question is what's the best way of letting the server get data from the class that instantiated it. I considered a callback, but I have yet to see an example that I could understand well enough to implement.
Thanks,
Jim.