overloaded functions in multiple inheritance.

D

DX

in MSVC7 the following seems to work:

class A { public: virtual void func1(void); };
class B { public: virtual void func2(void); };

class AB : public A, public B
{
virtual void A::func1(void) {return 0;};
virtual void B::func1(void) {return 1;};
}

This is great, except my two versions of func1 are actually huge, and
I'd like to put them into two separate files. In order to do this,
I'm doing something like:

class AB : public A, public B
{
virtual void A::func1(void);
virtual void B::func1(void);
}

void AB::A::func1(void)
{ return 0; };

void AB::A::func1(void)
{ return 1; };

However, when I do this, I get a compiler error:
error C2509: 'func1': member function not declared in 'AB'

Anyone have any clue what I'm doing wrong? Syntax error somewhere?
 
V

Victor Bazarov

DX said:
in MSVC7 the following seems to work:

class A { public: virtual void func1(void); };
class B { public: virtual void func2(void); };

Did you actually mean

class B { public: virtual void func1(void); };

???
class AB : public A, public B
{
virtual void A::func1(void) {return 0;};
virtual void B::func1(void) {return 1;};
}

Really? I just checked with 7.1, and as expected, the code is full
of errors.
This is great,

No, it isn't. Your code is not C++, how can it be "great"?
[..]
Anyone have any clue what I'm doing wrong? Syntax error somewhere?

Plenty. What are you trying to do?

V
 

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,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top