Created
October 28, 2014 21:27
-
-
Save cengiz-io/5b918ccdd1b8ef80dacd to your computer and use it in GitHub Desktop.
copy initialization and direct initialization
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
class A { | |
public: | |
A() { | |
cout << "default constructor" << endl; | |
} | |
A(const A& x) { | |
cout << "copy constructor" << endl; | |
} | |
const A& operator = (const A& x) { | |
cout << "operator =" << endl; | |
return *this; | |
} | |
}; | |
int main() { | |
A a; // default constructor | |
A b(a); // copy constructor | |
A c = a; // copy constructor | |
c = b; // operator = | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment