out of class declaration virtual function disambiguation

Discussion in 'C Programming' started by bonzo, Oct 14, 2008.

  1. bonzo

    bonzo

    Joined:
    Oct 14, 2008
    Messages:
    3
    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
     
    bonzo, Oct 14, 2008
    #1
    1. Advertising

  2. bonzo

    bonzo

    Joined:
    Oct 14, 2008
    Messages:
    3
    :-( nobody knows ?
     
    bonzo, Oct 15, 2008
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Xenos
    Replies:
    2
    Views:
    688
    Dave Moore
    Apr 29, 2004
  2. Ovidesvideo
    Replies:
    4
    Views:
    515
    Andrey Tarasevich
    Dec 10, 2004
  3. John Collins

    Template disambiguation

    John Collins, Dec 28, 2004, in forum: C++
    Replies:
    1
    Views:
    463
    Victor Bazarov
    Dec 29, 2004
  4. kelvSYC
    Replies:
    6
    Views:
    7,234
    Richard Herring
    May 17, 2005
  5. =?windows-1250?Q?Petr_Jake=9A?=
    Replies:
    11
    Views:
    1,521
    bearophileHUGS@lycos.com
    Aug 10, 2006
Loading...

Share This Page