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

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top