Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include "A.h"
- using namespace std; // Avoid extra typing, but is generally bad
- int main() {
- A obj1; // Default Constructor
- cout << "obj1: " << obj1 << endl;
- A* ptr_obj1; // Doesn't call anything
- cout << "ptr_obj1: " << "nullptr" << endl;
- A obj2(obj1); // Copy Construction (could use {} instead)
- cout << "obj2: " << obj2 << endl;
- obj1 = obj2; // Copy Assignment
- cout << "obj1: " << obj1 << endl << "obj2: " << obj2 << endl;
- A obj3(std::move(obj2)); // Move Construction
- cout << "obj2: " << "NULL" << endl << "obj3: " << obj3 << endl;
- obj1 = std::move(obj3); // Move Assignment
- cout << "obj1: " << obj1 << endl << "obj3: " << "NULL" << endl;
- ptr_obj1 = new A(); // Default Constructor
- cout << "ptr_obj1: " << *ptr_obj1 << endl;
- delete ptr_obj1;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement