H
HGallon
I have an application where I have visual elements which are a: Moving
or Stationary, and b: Static or Animated
//
using namespace std;
//
class element
{
public:
virtual void Paint (HDC hDC);
};
//
class movingElement : public element
{
public:
void Move ();
};
//
class animatedElement : public element
{
public:
void Update (); // get next image in
// animated sequence
};
//
class movingAnimatedElement : public movingElement,
public animatedElement
{
};
So far, so good. Now I need a container to display all visual elements
sorted by e.g. Z-Order
//
class elementList
{
protected:
list<element*> m_list;
public:
virtual void addElement (element* pEl);
};
Now, when adding all elements into a sorted list
//
void fn ()
{
element el;
movingElement mEl;
animatedElement aEl;
movingAnimatedElement maEl;
elementList elList;
elList.addElement (&el); // ok
elList.addElement (&mEl); // ok
elList.addElement (&aEl); // ok
elList.addElement (&maEl);
Error C2594: 'argument' : ambiguous conversions from 'class
movingAnimatedElement*' to 'class element*'
}
C2594 is defined as "'operator' : ambiguous conversions from 'type1' to
'type1' No conversion from one specified type to the other was more
direct than any other. It may be necessary to define or specify an
explicit conversion."
If I convert maEl to a movingElement, I can't update the animated image
frame; if I convert it to an animatedElement, I can't move it. And I'd
rather not add "virtual void Move ()" to the definition of element and
everything derived from it. Any help, anyone?
or Stationary, and b: Static or Animated
//
using namespace std;
//
class element
{
public:
virtual void Paint (HDC hDC);
};
//
class movingElement : public element
{
public:
void Move ();
};
//
class animatedElement : public element
{
public:
void Update (); // get next image in
// animated sequence
};
//
class movingAnimatedElement : public movingElement,
public animatedElement
{
};
So far, so good. Now I need a container to display all visual elements
sorted by e.g. Z-Order
//
class elementList
{
protected:
list<element*> m_list;
public:
virtual void addElement (element* pEl);
};
Now, when adding all elements into a sorted list
//
void fn ()
{
element el;
movingElement mEl;
animatedElement aEl;
movingAnimatedElement maEl;
elementList elList;
elList.addElement (&el); // ok
elList.addElement (&mEl); // ok
elList.addElement (&aEl); // ok
elList.addElement (&maEl);
Error C2594: 'argument' : ambiguous conversions from 'class
movingAnimatedElement*' to 'class element*'
}
C2594 is defined as "'operator' : ambiguous conversions from 'type1' to
'type1' No conversion from one specified type to the other was more
direct than any other. It may be necessary to define or specify an
explicit conversion."
If I convert maEl to a movingElement, I can't update the animated image
frame; if I convert it to an animatedElement, I can't move it. And I'd
rather not add "virtual void Move ()" to the definition of element and
everything derived from it. Any help, anyone?