| re: CLASS ?
tvn007 wrote:[color=blue]
> Could someone please help me or point/explain to me why the error in
> line 46 ?
>
> ////////////////////////Error message:////////////////////////////////
>
> bash-2.05b$ g++ test3.cpp
> test3.cpp: In function `int main()':
> test3.cpp:46: error: request for member `print_data' in `ptrstudent',
> which is
> of non-aggregate type `Record_info*'
> //////////////////////////////////////////////////////////////////////////////////////////////////
> [...]
> int main (void){
> Record_info student[MAX],*ptrstudent;[/color]
So, 'ptrstudent' is a _pointer_...
[color=blue]
> [...]
> ptrstudent.print_data(); //line 46[/color]
Pointers do not have members themselves. If you need to access a member
of a class to which the pointer points, you need to use '->' ("arrow")
operator:
ptrstudent->print_data();
[color=blue]
> [...][/color]
This is really a very basic stuff, I am surprised you needed to summon
the help of a newsgroup for that.
V |