tags:

views:

73

answers:

1

I am trying to inherit CObject but am failing to do so. My class looks like this:

class CCanMessage : public CObject
{
public:
    CCanMessage(void);
    ~CCanMessage(void);

    unsigned int m_id; //can-id
    CANMessageTypes m_msgType; //this is an enum 
    unsigned char m_len;
    char *m_pCmdStr;            
};

The constructor and destructor are empty.

When I compile I get error C2248: 'CObject::CObject' : cannot access private member declared in class 'CObject'. I have been looking for an explanation for some time now without finding one. I assume the error is embarrassingly simple, but I just can't seem to find it.

Worth noting is that if I don't use the CCanMessage class anywhere the compilation error disappears. The error points to the declaration of the class and not to any place I use the class.

A: 

I presume your issue is with this part from CObject (afx.h):

private:
CObject(const CObject& objectSrc);              // no implementation
void operator=(const CObject& objectSrc);       // no implementation

Try to provide implementations for the copy constructor and assignment operator for your CCanMessage.

Roel
Just found this out on my own too! Thanks for taking your time.
AnnaR