Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > overloaded functions in multiple inheritance.

Reply
Thread Tools

overloaded functions in multiple inheritance.

 
 
DX
Guest
Posts: n/a
 
      06-11-2004
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?
 
Reply With Quote
 
 
 
 
Victor Bazarov
Guest
Posts: n/a
 
      06-11-2004
"DX" <> wrote...
> 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


 
Reply With Quote
 
 
 
 
DaKoadMunky
Guest
Posts: n/a
 
      06-11-2004
You didn't state what it is you are trying to do but I am going to employ my
psychic powers and suggest that you take a look at this link...

http://www.gotw.ca/gotw/039.htm


 
Reply With Quote
 
DX
Guest
Posts: n/a
 
      06-11-2004
I was basically trying to have class AB implement two versions of
func1, one for each base class.

I thought this was not possible in C++. I was quite confused because
someone else passed me the original code. Anyways, I found my
solution here:

http://msdn.microsoft.com/library/de...m/deriv_14.asp

That was exactly what I was trying to do.
My guess is it's specific to MSVC, using the "interface" keyword.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
please help me in distinguish redefining functions, overloading functions and overriding functions. Xiangliang Meng C++ 1 06-21-2004 03:11 AM
overloaded functions in multiple inheritance. DX C++ 0 06-11-2004 08:47 PM
Compile error with overloaded functions Jef Driesen C++ 1 01-29-2004 03:29 PM
Overloaded functions kazack C++ 3 11-27-2003 04:18 PM
Overriding overloaded functions? Generic Usenet Account C++ 2 08-27-2003 05:41 AM



Advertisments