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

Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Dec 2007
Posts: 68
Reputation: Rhohitman is an unknown quantity at this point 
Solved Threads: 4
Rhohitman's Avatar
Rhohitman Rhohitman is offline Offline
Junior Poster in Training

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

 
0
  #1
Aug 26th, 2009
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
  1. typedef Table *Tptr;
  2. Tptr T1;
if yes please help me out
Chazing Dreams ;'P
Shhhh.......ZZzzzzzzzzzzzzzzzzzzzz.....
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 681
Reputation: Tom Gunn has much to be proud of Tom Gunn has much to be proud of Tom Gunn has much to be proud of Tom Gunn has much to be proud of Tom Gunn has much to be proud of Tom Gunn has much to be proud of Tom Gunn has much to be proud of Tom Gunn has much to be proud of Tom Gunn has much to be proud of Tom Gunn has much to be proud of 
Solved Threads: 133
Tom Gunn's Avatar
Tom Gunn Tom Gunn is offline Offline
Practically a Master Poster

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

 
0
  #2
Aug 26th, 2009
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:
  1. (*T1).reveal();
Because it is such a common operation, there is a special operator to make the whole thing simpler:
  1. T1->reveal();
-Tommy (For Great Justice!) Gunn
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 68
Reputation: Rhohitman is an unknown quantity at this point 
Solved Threads: 4
Rhohitman's Avatar
Rhohitman Rhohitman is offline Offline
Junior Poster in Training

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

 
0
  #3
Aug 26th, 2009
thank a lot.. i had never done this with the function..........................
Chazing Dreams ;'P
Shhhh.......ZZzzzzzzzzzzzzzzzzzzzz.....
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC