Created
April 13, 2015 07:14
-
-
Save david-bergstrom/d0f4485d6c26e33a3134 to your computer and use it in GitHub Desktop.
A small example of pointers of pointers in comparison pointers of instances.
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
struct Wheel { | |
int number; | |
}; | |
struct Car { | |
struct Wheel* wheel_pointer; | |
struct Wheel wheel_instance; | |
}; | |
int main() { | |
struct Car car; | |
struct Wheel wheel; | |
struct Car* c_pointer = &car; | |
car.wheel_pointer = &wheel; | |
c_pointer->wheel_pointer->number = 4; | |
c_pointer->wheel_instance.number = 2; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment