Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- class Bob
- {
- public:
- int test;
- int *ptest;
- Bob();
- ~Bob();
- Bob(Bob ©);
- };
- Bob::Bob()
- {
- ptest = new int;
- }
- Bob::~Bob()
- {
- delete ptest;
- }
- Bob::Bob(Bob ©)
- {
- test = copy.test;
- ptest = new int;
- *ptest = *(copy.ptest);
- }
- void some_function(Bob bob)
- {
- *(bob.ptest) = 5;
- }
- int main()
- {
- Bob bob;
- *(bob.ptest) = 7;
- some_function(bob);
- std::cout << *(bob.ptest) << std::endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment