out of class declaration virtual function disambiguation

Joined
Oct 14, 2008
Messages
3
Reaction score
0
I have a code like this:
Code:
struct A1{ virtual void DOH()=0 };
struct A2{ virtual void DOH()=0 };

struct B: public A1,A2{
    void A1::DOH(){ printf("doh!"); }
    void A2::DOH(){ printf("doh!"); }
};

that of course compiles correctly. The question is : what is the proper syntax
to declare the DOH's function bodies outside B declaration?
That is if I write
Code:
...
struct B: public A1,A2{
    void A1::DOH();
    void A2::DOH();
};
void B::A1::DOH(){ printf("doh!"); }
void B::A2::DOH(){ printf("doh!"); }

the compiler rises the error "the symbol to the left of a '::' must be a type"

thanks
 

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,994
Messages
2,570,223
Members
46,813
Latest member
lawrwtwinkle111

Latest Threads

Top