Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > what does this error means "cannot call member function 'X' without object "

Reply
Thread Tools

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

 
 
mahesh
Guest
Posts: n/a
 
      05-17-2007
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

 
Reply With Quote
 
 
 
 
red floyd
Guest
Posts: n/a
 
      05-17-2007
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-lit...t.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.





 
Reply With Quote
 
 
 
 
Ian Collins
Guest
Posts: n/a
 
      05-17-2007
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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
call member function without object-compile error eric C++ 6 06-22-2011 04:54 AM
Error - Cannot call member function without object... Elliott C++ 2 08-01-2007 06:49 PM
What is the correct grammar to make a function call by using static member data which is a pointer to a ordinary class member function? zaeminkr@gmail.com C++ 3 07-06-2007 12:50 PM
How do you call a regular member function from a static member function? aling C++ 6 10-30-2005 04:38 AM
parse error in gcc but success in vc.net, call a non_template class's template member function from a template class's member function! ken C++ 2 06-28-2005 06:57 AM



Advertisments