Last active
July 6, 2016 15:52
-
-
Save jacquelinekay/b6098b211beaf7d1cc53b2f0f12f70b7 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