| | |
Why Can`t member function be called by pointer object of class/struct
Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved |
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
if yes please help me out
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
C++ Syntax (Toggle Plain Text)
typedef Table *Tptr; Tptr T1;
Chazing Dreams ;'P
Shhhh.......ZZzzzzzzzzzzzzzzzzzzzz.....
Shhhh.......ZZzzzzzzzzzzzzzzzzzzzz.....
Member access through pointers is different. If you try to do something like
Because it is such a common operation, there is a special operator to make the whole thing simpler:
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: C++ Syntax (Toggle Plain Text)
(*T1).reveal();
C++ Syntax (Toggle Plain Text)
T1->reveal();
-Tommy (For Great Justice!) Gunn
![]() |
Similar Threads
- why can the reference data member be assigned in constant member function? (C++)
- OOP headache: pointer to a member function... (C++)
- quick synax question (C++)
- Passing a member function pointer (C++)
- Problem with pointer-to-function (C++)
- class struct fix 2 new errors need advice (C++)
- Return 2-dimensional vector array from function (C++)
- struct and member function pointer (C)
- performance benefit by not calling static member function by object (C)
- Need example of how to use INHERITANCE! (C++)
Other Threads in the C++ Forum
- Previous Thread: Screen Capture
- Next Thread: Get node number XX in BST
| Thread Tools | Search this Thread |
api array arrays based binary c++ c/c++ calculator char char* class classes code coding compile compiler console conversion convert count database delete deploy desktop developer directshow dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game generator givemetehcodez google graph gui homeworkhelp iamthwee ifstream input int java lib linkedlist linker list loop looping loops map math matrix memory multiple news number numbertoword output pointer problem program programming project python random read recursion recursive reference rpg sorting string strings temperature template templates test text text-file tree unix url variable vector video visual visualstudio win32 windows winsock wordfrequency wxwidgets





