Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- #include <stdio.h>
- class A {
- public:
- A() { _objName = "no name"; };
- A(string objName) {
- _objName = objName;
- printf("Constructor %s\n", _objName.c_str());
- };
- ~A() {
- printf("Destructor %s\n",_objName.c_str());
- };
- A(const A& obj) {
- printf("Deep copy when initial.\n");
- }
- A(const A&& obj) {
- printf("Shadow copy when initial.\n");
- }
- A copy(void){
- return *this;
- }
- string _objName = "default";
- };
- A copy(string objName)
- {
- A b(objName);
- return b;
- }
- int main() {
- A a("a");
- a.copy();
- printf("\n------------------------------------\n\n");
- A c(copy("b"));
- printf("\n------------------------------------\n\n");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement