referencing

Discussion in 'C++' started by Michael Sgier, Sep 11, 2005.

  1. Hello
    in my header file i've:
    class CSimpEngine : public CEngine
    {

    CSimpEngine()
    {
    ....
    }

    i get here the error: undefined reference to `vtable for CSimpEngine'
    and in my class CEngine i've:

    class CEngine
    {
    public:
    CEngine() {}
    ~CEngine() {}
    };
    What am i doing wrong? What is vtable?
    THANKS and regards
    Michael
     
    Michael Sgier, Sep 11, 2005
    #1
    1. Advertising

  2. Michael Sgier

    John Carson Guest

    "Michael Sgier" <> wrote in message
    news:4323f080$0$1146$
    > Hello
    > in my header file i've:
    > class CSimpEngine : public CEngine
    > {
    >
    > CSimpEngine()
    > {
    > ...
    > }
    >
    > i get here the error: undefined reference to `vtable for CSimpEngine'
    > and in my class CEngine i've:
    >
    > class CEngine
    > {
    > public:
    > CEngine() {}
    > ~CEngine() {}
    > };
    > What am i doing wrong? What is vtable?
    > THANKS and regards
    > Michael


    You won't get that error from the code you have shown. Show us real code
    that exhibits the problem.

    --
    John Carson
     
    John Carson, Sep 11, 2005
    #2
    1. Advertising

  3. Michael Sgier wrote:
    > Hello
    > in my header file i've:
    > class CSimpEngine : public CEngine
    > {
    >
    > CSimpEngine()
    > {
    > ...
    > }
    >
    > i get here the error: undefined reference to `vtable for CSimpEngine'
    > and in my class CEngine i've:
    >
    > class CEngine
    > {
    > public:
    > CEngine() {}
    > ~CEngine() {}
    > };
    > What am i doing wrong? What is vtable?
    > THANKS and regards
    > Michael


    That error usually happens because you declared a virtual function but
    forgot to define it.

    But there are no virtual functions in the code you posted. If you want
    help with code it always helps to post the actual code, instead of the
    pieces of the code that you think might be relevant.

    Of course this doesn't mean that you should post pages and pages of
    code. Instead when you have an error you don't understand, spend some
    time to create the smallest possible program that still has the error
    you don't understand, then post the whole program. Not only will this be
    a good learning exercise for you it also ensures that you will get your
    questions answered promptly and accurately.

    john
     
    John Harrison, Sep 11, 2005
    #3
  4. Hello again
    in Main.cpp i've:
    CSimpEngine* MyCSimpEngine = new CSimpEngine;

    and i've added in simpengine.cpp this:
    CSimpEngine::CSimpEngine()
    {
    gameCamera = new CCamera;
    }

    CSimpEngine::~CSimpEngine()
    {
    delete gameCamera;
    gameCamera = NULL;
    }

    do i need to do that? I have the declaration in simpengine.h as in my
    previous mail.
    and i still get the same error:
    main.o(.gnu.linkonce.t._ZN11CSimpEngineC1Ev+0x1b): In function
    `CSimpEngine::CSimpEngine[in-charge]()':
    /home/michael/Desktop/div.OpenGL/agentin_laura/src/simpengine.h:32:
    undefined reference to `vtable for CSimpEngine'
    THANKS Michael
     
    Michael Sgier, Sep 11, 2005
    #4
  5. Maybe like this it's clearer. My simpengine.h:

    class CSimpEngine : public CEngine
    {
    public:
    CSimpEngine()
    {
    gameCamera = new CCamera;
    }

    ~CSimpEngine()
    {
    delete gameCamera;
    gameCamera = NULL;
    }
    };
     
    Michael Sgier, Sep 11, 2005
    #5
  6. Michael Sgier

    John Carson Guest

    "Michael Sgier" <> wrote in message
    news:43240839$0$1164$
    > Maybe like this it's clearer. My simpengine.h:
    >
    > class CSimpEngine : public CEngine
    > {
    > public:
    > CSimpEngine()
    > {
    > gameCamera = new CCamera;
    > }
    >
    > ~CSimpEngine()
    > {
    > delete gameCamera;
    > gameCamera = NULL;
    > }
    > };


    This is completely useless. Read what John Harrison wrote.

    1. Simplify the code as far as you can while still getting the error.
    2. Then supply us with the EXACT and COMPLETE code from 1. that you run
    through the compiler.

    Since you appear to have some psychological resistance to doing what is
    necessary, let me make two points.

    First, you don't know what the problem is otherwise you wouldn't be posting
    here. That means that you don't know where in your code the problem is and
    hence your attempts to select relevant code are very likely to fail.

    Second, your attempts to select relevant code have in fact failed. Consider
    the following code, which consists of everything you have posted, plus a few
    other details that I have filled in. It compiles without any errors. Thus
    the problem is not in the code you have posted. Don't waste any more time
    supplying selected excerpts.

    #include <cstdlib>

    class CEngine
    {
    public:
    CEngine() {}
    ~CEngine() {}
    };

    class CCamera
    {};

    class CSimpEngine : public CEngine
    {
    public:
    CSimpEngine()
    {
    gameCamera = new CCamera;
    }

    ~CSimpEngine()
    {
    delete gameCamera;
    gameCamera = NULL;
    }
    private:
    CCamera *gameCamera;
    };

    int main()
    {
    CSimpEngine* MyCSimpEngine = new CSimpEngine;
    return 0;
    }

    --
    John Carson
     
    John Carson, Sep 11, 2005
    #6
    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. K. Shier
    Replies:
    6
    Views:
    529
    K. Shier
    Oct 10, 2003
  2. geoffrey wall

    vhdl source cross-referencing tool

    geoffrey wall, Jul 1, 2005, in forum: VHDL
    Replies:
    7
    Views:
    2,044
    Ajeetha
    Jul 7, 2005
  3. John
    Replies:
    2
    Views:
    386
    David Waz...
    Jul 8, 2003
  4. Mark Friedman

    Referencing subcontrols within UserControl

    Mark Friedman, Jul 9, 2003, in forum: ASP .Net
    Replies:
    4
    Views:
    389
    Christopher Young
    Jul 14, 2003
  5. William F. Robertson, Jr.

    Re: Referencing Custom Page Class within a Control

    William F. Robertson, Jr., Jul 10, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    385
    Cheung, Jeffrey Jing-Yen
    Jul 10, 2003
Loading...

Share This Page