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

M

mahesh

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
 
R

red floyd

mahesh said:
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.
 
I

Ian Collins

mahesh said:
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?
 

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

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top