order of base class declaration

S

Sandeep Pulla

Can anyone shed light on why the following gives the compile time
error:

'entity *surface_entity::clone(void)' : overloaded member function not
found in 'surface_entity'

=========================================================================
class entity {
public:
virtual entity* clone() const = 0;
};

class surface {
protected:
virtual void redo_caches() const {}
};

class surface_entity : public surface, public entity {
public:
surface_entity* clone() const { return new surface_entity(*this); }
private:
void redo_caches() const {}
};
=========================================================================

Whereas either

[a] Making either "clone()" OR "redo_caches()" non-virtual

or

Changing the order of base class declaration, i.e., "public
entity, public surface" instead of "public surface, public entity"

makes the error go away?


Thanks in advance,
Sandeep

p.s. the compiler is microsoft visual c++ 7
 
R

Ron Natalie

Sandeep Pulla said:
Can anyone shed light on why the following gives the compile time
error:

'entity *surface_entity::clone(void)' : overloaded member function not
found in 'surface_entity'

Most likely that your compiler doesn't implement covariant return types.
Try defining surface_entity::clone() to return entity*.
p.s. the compiler is microsoft visual c++ 7

Try asking in microsoft.public.vc.language. They're more familiar with VC++'s
bugs and limitations there.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top