0

I have inhereted CAsyncSocket and wanted to pass the objects around.

 class ClientSocket : public CAsyncSocket
{
CAsyncSocket nitSocket;
    public:
ClientSocket(void);
virtual ~ClientSocket(void);
 };

I get sevaral compile errors when i do

 void SomeOtherClass::func(ClientSocket &socket)
     this->socket = socket;
 }

Error:

'CAsyncSocket::operator =' : cannot access private member declared in class          'CAsyncSocket'

I looked into file and found

private:
CAsyncSocket(const CAsyncSocket& rSrc);    // no implementation
void operator=(const CAsyncSocket& rSrc);  // no implementation

Should i make my copy constructor but since there is no implementation for base class would my code crash at runtime.

Important: Should i make a copy ? WOULD my new object receive the events of original object?

Ashish Negi
  • 5,193
  • 8
  • 51
  • 95

1 Answers1

0

Polymorphic types in C++ are usually made non-copyable because taking a copy of base class easily leads to slicing.

Community
  • 1
  • 1
Nikolai Fetissov
  • 82,306
  • 11
  • 110
  • 171