954,160 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Why Can`t member function be called by pointer object of class/struct

Why Can`t member function be called by pointer object of class/struct.

i was trying to call the member fuction of struct though pointer object it showed me error like

request for member 'Table::reveal' in `T1`, which is of non-class type 'Table*'

where,
Table is structure
reveal is member function
T1 is the object pointer object created though

typedef Table *Tptr;
             Tptr T1;

if yes please help me out

Rhohitman
Junior Poster in Training
83 posts since Dec 2007
Reputation Points: 10
Solved Threads: 5
 

Member access through pointers is different. If you try to do something like T1.reveal() , you would get that error because the dot operator does not work with pointers. You need to dereference the pointer first, then do the access:

(*T1).reveal();

Because it is such a common operation, there is a special operator to make the whole thing simpler:

T1->reveal();
Tom Gunn
Master Poster
733 posts since Jun 2009
Reputation Points: 1,446
Solved Threads: 135
 

thank a lot.. i had never done this with the function..........................

Rhohitman
Junior Poster in Training
83 posts since Dec 2007
Reputation Points: 10
Solved Threads: 5
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You