Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
C/C++ - Problemi con l'ereditarietà
Forum - C/C++ - Problemi con l'ereditarietà

Avatar
robrock80 (Normal User)
Pro


Messaggi: 143
Iscritto: 11/12/2006

Segnala al moderatore
Postato alle 11:25
Mercoledì, 07/04/2010
Salve a tutti. Dato le seguenti classi definite in un file header.

Codice sorgente - presumibilmente C++

  1. class Server : public MicrosoftWindowsService {
  2.                 public:
  3.                         static char* NAME_PATTERN;
  4.                         Server(unsigned int port = 80, unsigned int maxCl = 1);
  5.                         virtual ~Server();
  6.                         SOCKET getSocket();
  7.                         virtual void doService();
  8.                         virtual void endService();
  9.                         int getListenPort() const{
  10.                                 return listenPort;
  11.                         }
  12.                         void init();
  13.  
  14.                 protected:
  15.                         virtual void createSocketManagers(int);
  16.  
  17.                 private:
  18.                         int listenPort;
  19.                         SOCKET serverSocket;
  20.                         void deleteSocketManagers();
  21.                         void setToFalseSocketManagersIsListeningAndIsClientConnected();
  22.                         void startSocketManagers();
  23.                         void stopSocketManagers();
  24.                         void stopSocketManagersAndWaitUntilAllAreShutedDown();
  25.                         void waitUntilAllSocketManagersAreListening();
  26.  
  27.         };
  28.  
  29.         class MyServer: public Server {
  30.                 public:
  31.                         MyServer(unsigned int port, unsigned int maxCl) : Server(port, maxCl){};
  32.                         virtual ~MyServer(){};
  33.  
  34.                 protected:
  35.                         virtual void createSocketManagers(int);
  36.         };




Qualcuno riesce a capire perchè se istanzio la classe Server il compilatore compila e invece se istanzio la classe MyServer mi dà il seguente errore?

src\Main.o: In function `ZN7ServiceIPvmE4stopEv':
C:/Workspaces/Eclipse/C-C++/MY-SHARED-LIBRARY/src/UtilCPP.h:(.text$_ZN8MyServerD1Ev[MyServer::~MyServer()]+0xb): undefined reference to `vtable for MyServer'
C:/Workspaces/Eclipse/C-C++/MY-SHARED-LIBRARY/src/UtilCPP.h:(.text$_ZN8MyServerC1Ejj[MyServer::MyServer(unsigned int, unsigned int)]+0x24): undefined

PM Quote