Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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;
- }
Add Comment
Please, Sign In to add comment