Compile error with virtual inheritance: const <anonymous>** - AGAIN

Discussion in 'C++' started by Thomas Zangl, Jan 14, 2006.

  1. Thomas Zangl

    Thomas Zangl Guest

    Hi!

    First - thanks for your previous replies! After fixing the c'tor
    everything went fine until ... I added one more class in the hierachie.

    I have a class hierachie like this:

    // interface, abstract only
    class ISession {

    }

    // implements common parts of ISession
    class Session: public virtual ISession {
    public:
    Session(Socket* conn);

    }

    // implements the rest of ISession
    class P2PSession: public virtual Session {
    public:
    P2PSession(Socket* conn);
    }

    and I added one more class:

    class P2PClient: public virtual P2PSession
    {
    public:
    P2PClient(Socket* conn);
    }

    I get this error on compile:

    g++ -c -g -Wall -O2 -I./include -o src/P2PClient.o src/P2PClient.cpp
    src/P2PClient.cpp: In constructor `
    FTPServer_::p2PClient::p2PClient(FTPServer_::Socket*)':
    src/P2PClient.cpp:10: error: no matching function for call to `
    FTPServer_::Session::Session(const <anonymous>**)'
    include/Session.h:10: error: candidates are:
    FTPServer_::Session::Session(const
    FTPServer_::Session&)
    include/Session.h:12: error:
    FTPServer_::Session::Session(FTPServer_::Socket*)
    make: *** [src/P2PClient.o] Fehler 1

    The c'tor of P2PSession:

    //----------------------------------------------------------------------
    P2PSession::p2PSession(Socket* conn) : Session(conn)
    {
    }

    The c'tor of P2PClient:
    //----------------------------------------------------------------------
    P2PClient::p2PClient(Socket* conn): P2PSession(conn),
    state_(CS_INIT_NEEDED)
    {
    }

    Any ideas?

    TIA,
    --
    ----------------------------------------------------------------
    ,yours Thomas Zangl - - http://www.tzis.net/ -
    - Freelancer - IT Consulting & Software Development -
    Use Y.A.M.C! now! Get it at http://www.borg-kindberg.ac.at/yamc/
     
    Thomas Zangl, Jan 14, 2006
    #1
    1. Advertising

  2. Thomas Zangl

    Thomas Zangl Guest

    Re: Compile error with virtual inheritance: const <anonymous>** -AGAIN

    Thomas Zangl wrote:

    Hi!

    > // implements the rest of ISession
    > class P2PSession: public virtual Session {
    > public:
    > P2PSession(Socket* conn);
    > }


    Fixed it by removing "virtual" in the inhertiance of P2PSession from
    Session.

    I now tried to inherit P2PClient from the interface "INFSObserver" but
    the linker gives me an error:

    src/P2PClient.o(.text+0xed): In function
    `FTPServer_::p2PClient::~P2PClient [in-charge]()':
    include/INFSObserver.h:12: undefined reference to `vtable for
    FTPServer_::INFSObserver'
    src/P2PClient.o(.text+0x13d): In function
    `FTPServer_::p2PClient::~P2PClient [in-charge deleting]()':
    include/INFSObserver.h:12: undefined reference to `vtable for
    FTPServer_::INFSObserver'
    src/P2PClient.o(.gnu.linkonce.r._ZTIN10FTPServer_9P2PClientE+0x18):include/ISession.h:28:
    undefined reference to `typeinfo for FTPServer_::INFSObserver'
    collect2: ld returned 1 exit status
    make: *** [ftpserver] Fehler 1


    INFSObserver.h is included in P2PClient.h

    The inheritance looks like this now:

    class P2PClient: public virtual P2PSession, public virtual INFSObserver
    {
    public:
    ......
    }

    Any ideas?

    TIA :)
    --
    ----------------------------------------------------------------
    ,yours Thomas Zangl - - http://www.tzis.net/ -
    - Freelancer - IT Consulting & Software Development -
    Use Y.A.M.C! now! Get it at http://www.borg-kindberg.ac.at/yamc/
     
    Thomas Zangl, Jan 14, 2006
    #2
    1. Advertising

  3. Thomas Zangl

    Thomas Zangl Guest

    Re: Compile error with virtual inheritance: const <anonymous>** -AGAIN

    Thomas Zangl wrote:

    Hi,

    > // implements the rest of ISession
    > class P2PSession: public virtual Session {
    > public:
    > P2PSession(Socket* conn);
    > }


    removed the "virtual" inheritance and everything works fine now!

    Best regards,
    --
    ----------------------------------------------------------------
    ,yours Thomas Zangl - - http://www.tzis.net/ -
    - Freelancer - IT Consulting & Software Development -
    Use Y.A.M.C! now! Get it at http://www.borg-kindberg.ac.at/yamc/
     
    Thomas Zangl, Jan 14, 2006
    #3
    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. Alexander Stippler

    virtual inheritance / dreaded diamond again

    Alexander Stippler, Aug 26, 2003, in forum: C++
    Replies:
    1
    Views:
    390
    Ron Natalie
    Aug 26, 2003
  2. Xiangliang Meng
    Replies:
    2
    Views:
    413
    Jack Klein
    Jun 21, 2004
  3. Thomas Zangl
    Replies:
    11
    Views:
    544
    mlimber
    Jan 13, 2006
  4. Replies:
    11
    Views:
    1,109
  5. Javier
    Replies:
    2
    Views:
    572
    James Kanze
    Sep 4, 2007
Loading...

Share This Page