Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- class A{
- public:
- A( int n= 0 )
- : m_n( n )
- {
- std::cout << " init" << std::endl;
- }
- A( const A& a )
- : m_n( a.m_n )
- {
- std::cout << "copy" << std::endl;
- }
- private:
- int m_n;
- };
- void f( const A &a1, const A &a2 = A() ){
- }
- int main(){
- std::cout << "Line1" << std::endl;
- A a(2), b; //init init
- std::cout << "Line2" << std::endl;
- const A c(a), &d=c, e=b; //copy, copy, copy
- std::cout << "Line3" << std::endl;
- b =d; //copy
- std::cout << "Line4" << std::endl;
- A *p = new A(c), *q = &a; //init, init, copy
- std::cout << "Line5" << std::endl;
- static_cast<void>(q); //Que?
- std::cout << "Line6" << std::endl;
- delete p; //Nvmd.
- std::cout << "Line7" << std::endl;
- f(3); //meebe copy then copy?
- std::cout << "Line8" << std::endl;
- std::cout << std::endl;
- std::cout << "Line9" << std::endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement