Skip to content

Instantly share code, notes, and snippets.

@kitschpatrol
Created November 12, 2011 21:39
Show Gist options
  • Save kitschpatrol/1361157 to your computer and use it in GitHub Desktop.
Save kitschpatrol/1361157 to your computer and use it in GitHub Desktop.
pointer weirdness
// 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