Hi all,
I have been kind of forced (honestly) into writing a class structure
which contains a Diamond of Death, and I'm not entirely sure what to
do about it. This is a simplified version of my class structure:
class entity
{
public:
entity() {}
int a;
};
class item : public entity
{
public:
item() {}
int b;
};
class loop : public virtual item
{
public:
loop() {}
int c;
};
class path : public virtual item
{
public:
path() {}
int d;
};
class test : public path, public loop
{
public:
test() {}
int e;
};
int _tmain(int argc, _TCHAR* argv[])
{
ENTITY *entity_test = new test();
ENTITY *entity_loop = new loop();
loop* l = (loop*)entity_loop; // cannot convert a 'ENTITY*' to a
'loop*'
// conversion from a virtual base
class is implied
test* t = (test*)entity_test; // cannot convert a 'ENTITY*' to a
'test*'
// conversion from a virtual base
class is implied
return 0;
}
Can anyone tell me what I'm doing wrong?
Many thanks in advance for any help or advice.
Hugo Elias