Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Tricky CObArray Problem 1

Status
Not open for further replies.

JBravo

Programmer
Mar 21, 2002
12
IE
Hi All,
I'm having a bit of trouble adding derived objects of CObject to a CObArray object. I get the following error:
error C2243: 'type cast' : conversion from 'DoobyObj *__w64 ' to 'CObject *' exists, but is inaccessible


This is just a test for a later prject (hence the stupid class name). I need the DoobyObj class to inherit from CObject class so that I can serialize the CObArray object.
The error occurs on the Add line:

Code:
void SerObject::addDoobyObject(DoobyObj dO)
{
obaObjects.Add(&dO); //CObArray 
resetIndex();
}

Here is the definition of DoobyObj:

class DoobyObj : CObject
{
public:
DECLARE_SERIAL( DoobyObj )
DoobyObj();
void Serialize(CArchive& archive );
CString dooby;
};

Can anyone solve my problem??
Thanks,
Donal
 
Here's what MSDN has to say about this error:


'conversion type' conversion from 'type1' to 'type2' exists, but is inaccessible

A pointer to a derived class was converted to a pointer to a base class, but the derived class inherited the base class with private or protected access.

The following is an example of this error:

class B {};
class D : private B {};

D d;
B *p = &d; // error


Try

class DoobyObj : public CObject

It looks like inheritance is private by default? I always state explicitely, to avoid confusion.

Vincent
 
Thanks Vincent,
That solved my problem.
Donal
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top