what does this error means "cannot call member function 'X' without object "

Discussion in 'C++' started by mahesh, May 17, 2007.

  1. mahesh

    mahesh Guest

    Can anyone direct me to the place where i find the solution for the
    error message "cannot call member function 'X' without object"???
    thanks in advance
     
    mahesh, May 17, 2007
    #1
    1. Advertising

  2. mahesh

    red floyd Guest

    Re: what does this error means "cannot call member function 'X' withoutobject "

    mahesh wrote:
    > Can anyone direct me to the place where i find the solution for the
    > error message "cannot call member function 'X' without object"???
    > thanks in advance
    >


    Yes, try http://www.parashift.com/c -faq-lite/how-to-post.html#faq-5.8

    However, the error is fairly clear. You are trying to call a member
    function X. You must have an object to call X on, e.g.

    either

    T obj;
    obj.X();

    or

    T *obj = new T;
    obj->X();

    Since I doubt that you are making a T::X() call directly in your code, I
    suspect you have a static member function in T, and are trying to call
    X() from within it. Won't work. A static member function doesn't have
    a this pointer, so you still need a pointer to, a reference to, or an
    actual T object to call X() on.
     
    red floyd, May 17, 2007
    #2
    1. Advertising

  3. mahesh

    Ian Collins Guest

    Re: what does this error means "cannot call member function 'X' withoutobject "

    mahesh wrote:
    > Can anyone direct me to the place where i find the solution for the
    > error message "cannot call member function 'X' without object"???
    > thanks in advance
    >

    The place in your code where you attempt to call a class member function
    without an instance of the class?

    --
    Ian Collins.
     
    Ian Collins, May 17, 2007
    #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. Rookie
    Replies:
    4
    Views:
    14,790
    Chris Langsenkamp
    Aug 20, 2003
  2. news.microsoft.com
    Replies:
    1
    Views:
    1,247
    Justin Martin
    Aug 10, 2003
  3. ronaldlee
    Replies:
    3
    Views:
    3,593
    Hans Kesting
    Dec 16, 2004
  4. Vijay
    Replies:
    1
    Views:
    3,282
    Martin Honnen
    Mar 22, 2005
  5. gk
    Replies:
    8
    Views:
    10,436
    Kent Paul Dolan
    May 24, 2006
Loading...

Share This Page