Skip to content

Instantly share code, notes, and snippets.

@tk0221
Last active January 4, 2016 04:39
Show Gist options
  • Save tk0221/8569737 to your computer and use it in GitHub Desktop.
Save tk0221/8569737 to your computer and use it in GitHub Desktop.
cpp example code
#include <iostream>
using namespace std;
struct Rectangle {
int x, y;
int width, height;
};
int main() {
Rectangle rc = {100, 100, 50, 50};
Rectangle* p = &rc;
//cout
cout << "before\n" ;
cout << "rc.x = " << rc.x << " rc.y = " << rc.y << "\n" ;
(*p).x = 200; // same as rc.x
p->y = 999;
//cout
cout << "after\n" ;
cout << "rc.x = " << rc.x << " rc.y = " << rc.y << "\n" ;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment