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

T

Thomas Zangl

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,
 
T

Thomas Zangl

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 :)
 
T

Thomas Zangl

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,
 

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,764
Messages
2,569,567
Members
45,042
Latest member
icassiem

Latest Threads

Top