Created
November 12, 2011 21:39
-
-
Save kitschpatrol/1361157 to your computer and use it in GitHub Desktop.
pointer weirdness
This file contains hidden or 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
| // interface | |
| class Skeleton { | |
| public: | |
| Skeleton(); | |
| ofPoint head; | |
| ofPoint neck; | |
| ofPoint leftShoulder; | |
| ofPoint leftElbow; | |
| ofPoint leftHand; | |
| ofPoint rightShoulder; | |
| ofPoint rightElbow; | |
| ofPoint rightHand; | |
| ofPoint torso; | |
| ofPoint leftHip; | |
| ofPoint leftKnee; | |
| ofPoint leftFoot; | |
| ofPoint rightHip; | |
| ofPoint rightKnee; | |
| ofPoint rightFoot; | |
| ofPoint * joints[15]; | |
| }; | |
| // Implementation | |
| Skeleton::Skeleton() { | |
| reset(); // sets all the ofPoints to -1, -1, -1 | |
| joints[0] = &head; | |
| joints[1] = &neck; | |
| joints[2] = &leftShoulder; | |
| joints[3] = &leftElbow; | |
| joints[4] = &leftHand; | |
| joints[5] = &rightShoulder; | |
| joints[6] = &rightElbow; | |
| joints[7] = &rightHand; | |
| joints[8] = &torso; | |
| joints[9] = &leftHip; | |
| joints[10] = &leftKnee; | |
| joints[11] = &leftFoot; | |
| joints[12] = &rightHip; | |
| joints[13] = &rightKnee; | |
| joints[14] = &rightFoot; | |
| cout << joints[0]->x << endl; // this returns a memory address, not the value of head.x! | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment