Skip to content

Instantly share code, notes, and snippets.

@dadarek
Created June 29, 2012 21:17
Show Gist options
  • Save dadarek/3020701 to your computer and use it in GitHub Desktop.
Save dadarek/3020701 to your computer and use it in GitHub Desktop.
Lesson on Pointers
class Wheels
{
public:
Wheels(){
cout << "Wheel constructor" << endl;
}
void spin() {
cout << "I'm spinning ... " << endl;
}
};
void lessonOnPointers() {
Wheels* w = new Wheels();
w->spin(); // w is a pointer
(*w).spin(); // (*w) is an object
(&(*w))->spin(); // &(*w) is a pointer
(*(&(*w))).spin(); // *(&(*w)) is an object
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment