Created
July 6, 2016 15:51
-
-
Save jacquelinekay/4ad0db51923f67e24782ddf849972ca8 to your computer and use it in GitHub Desktop.
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> | |
class A { | |
public: | |
A(const char * foo) { | |
std::cout << "Invoking constructor" << std::endl; | |
s = std::string(foo); | |
} | |
A(const A& a) { | |
std::cout << "Invoking copy constructor" << std::endl; | |
s = a.s; | |
} | |
A(A&& a) { | |
std::cout << "Invoking move constructor" << std::endl; | |
s = a.s; | |
} | |
std::string s; | |
}; | |
static A construct(const char * foo) { | |
A a(foo); | |
return a; | |
} | |
int main() { | |
A && a = construct("hello world"); | |
std::cout << "Value of a: " << a.s << std::endl; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment