Hello, just a smal question, In some codes(In a tutoriao on this site too) I have seen this "->" with some kind of pointers, but I just can't understand what this do, what does it do? How do i use it? Please let me know, thanks ^_^
Hello, just a smal question, In some codes(In a tutoriao on this site too) I have seen this "->" with some kind of pointers, but I just can't understand what this do, what does it do? How do i use it? Please let me know, thanks ^_^
Is the same as:Code:string *blah; if((*blah).empty()) return;
The -> operator merely dereferences the pointer so it can call a class function like an object.Code:string *blah; if(blah->empty()) return;
Code:Error W8057 C:\\Life.cpp: Invalid number of arguments in function run(Brain *)
it is a more visually pleasing way of accessing the members of a structure through a pointer .... see this example:
which is a function used to access this struct:Code:void print_person ( struct Person *pers ) { printf ( "Name: %s\n", pers->name ); printf ( "Age: %d years\n", pers->age ); printf ( "Height: %.2f feet\n", pers->height ); }
it's all from the FAQ ... here just over half ways downCode:struct Person { char *name; int age; struct Height };
Last edited by twomers; 02-21-2006 at 06:14 AM.