Created
June 13, 2012 06:16
-
-
Save shunirr/2922187 to your computer and use it in GitHub Desktop.
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
typedef struct { | |
int *p; | |
} Mashiro; | |
void fuga(const Mashiro& a) | |
{ | |
Mashiro b = a; // コピーされる | |
*(b.p) = 20; // アドレスごとコピーされているので、これは a.p に影響する | |
} | |
int main() | |
{ | |
Mashiro mashiro; | |
int i = 10; | |
mashiro.p = &i; | |
fuga(mashiro); | |
*(mashiro.p); // => 20; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment