Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- struct A
- {
- A()
- {
- std::cout << "A()" << std::endl;
- }
- A(const A&)
- {
- std::cout << "A(const A&)" << std::endl;
- }
- ~A()
- {
- std::cout << "~A()" << std::endl;
- }
- };
- A func1()
- {
- A a;
- return a;
- }
- A func2()
- {
- return A();
- }
- int main()
- {
- std::cout << "func1" << std::endl;
- A a1 = func1();
- std::cout << "func2" << std::endl;
- A a2 = func2();
- std::cout << "finish" << std::endl;
- return 0;
- }
- /* output:
- func1
- A()
- A(const A&)
- ~A()
- A(const A&)
- ~A()
- func2
- A()
- A(const A&)
- ~A()
- A(const A&)
- ~A()
- finish
- ~A()
- ~A()
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement