Created
June 29, 2012 21:17
-
-
Save dadarek/3020701 to your computer and use it in GitHub Desktop.
Lesson on Pointers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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