Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Copy Constructor
- #include <iostream>
- using namespace std;
- class Myclass {
- public:
- Myclass() {
- cout << "default constructor" << endl;
- }
- Myclass(const Myclass &r)
- {
- cout << "***********************************" << endl;
- cout << "copy constructor" << endl;
- cout << "this = " << this << endl;
- cout << "&r = " << &r << endl;
- cout << "***********************************" << endl;
- }
- };
- void gfunc(Myclass m)
- {
- cout << "gfunc cagrildi" << endl;
- cout << "&m = " << &m << endl;
- cout << "---------------------------------------------" << endl;
- }
- int main()
- {
- Myclass m1;
- cout << "&m1 = " << &m1 << endl;
- gfunc(m1);
- return 0;
- }
- /*
- default constructor
- &m1 = 0x7ffeeeeb0468
- ***********************************
- copy constructor
- this = 0x7ffeeeeb0460
- &r = 0x7ffeeeeb0468
- ***********************************
- gfunc cagrildi
- &m = 0x7ffeeeeb0460
- ---------------------------------------------
- */
Add Comment
Please, Sign In to add comment