0

If I have a class called cdrom, and one of the member functions is loadinfo, what is the difference in these calls?

cd1.loadinfo

cd1->loadinfo

I ask because my compiler is choking on the first and actually asking me if I meant to do the second.

2
Contributors
3
Replies
4
Views
9 Years
Discussion Span
Last Post by mitrmkar
0

Consider the following

// A variable of class cdrom on the stack
cdrom cdrom1;
// invoke the loadinfo() member function
cdrom1.loadinfo();

// Allocate a variable of class cdrom on the heap
cdrom * cdrom_ptr = new cdrom;
// invoke the loadinfo() member function
cdrom_ptr->loadinfo();
0

static actually is not a good word to use here. Let's say for simplicity's sake that, if you have a pointer to a struct/class to work with, then you use the -> operator to access member variables/functions through that pointer.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.