Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class Foo {
- int x;
- public:
- Foo() {
- cout << "Default constructor" << endl;
- }
- Foo(int x) {
- cout << "Constructor that takes int" << endl;
- this->x = x;
- }
- Foo(const Foo& other) {
- cout << "Copy constructor" << endl;
- this->x = other.x;
- }
- Foo& operator = (const Foo& other) {
- cout << "Assignment operator" << endl;
- this->x = other.x;
- }
- ~Foo() {
- cout << "Destructor" << endl;
- }
- };
- int main() {
- Foo x;
- Foo y(2);
- Foo z(x);
- Foo t = z;
- Foo u;
- u = t;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement