First time I post so hello world!
The thing is that I’m familiarized with other PL and now I have to do a little project with OF and I’m having a problem that I’m not able to solve. I want to create a class which has an instance variable which is a ofxTCPClient because my app has to communicate with multiple servers. The problem is that when I add to the class “ofxTCPClient tcpClient;” I get this errors:
- “operator= is a private member of ofxTCPClient” (in myClass.h)
- “no matching constructor for initialization of myClass” (in vector.tcc)
- "field of type ‘ofxTCPManager’ has private copy constructor (in ofxTCPClient.h)
I don’t have any clue of what’s going on…
Anyone can help me?
Thank you very much in advange!
do you have some sample code ?
That error means that a class can’t be copied. TCPClient opens a network socket so copying it would mean making a copy of the socket which doesn’t make sense so the class itself disallows making copies.
If you are not trying to explicitly copy the class like:
ofxTCPClient client2 = client1;
or anything similar, the error might happen cause you are trying to put the class or a clas containing it into a vector like:
which will actually make a copy of client into clients which is disallowed. This same error can happen if you try to push_back into a vector a class that contains an ofxTCPClient.
To avoid it instead of using push_back you can use emplace_back like:
which directly creates the client in the vector instead of outside and then making a copy of it.