Last active
January 4, 2016 04:39
-
-
Save tk0221/8569737 to your computer and use it in GitHub Desktop.
cpp example code
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
#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