Created
March 29, 2017 09:51
-
-
Save hryniuk/f1a1a5ce0761e91250d388f5df4672a3 to your computer and use it in GitHub Desktop.
Constructor glitch
This file contains hidden or 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> | |
struct A | |
{ | |
A() { std::cout << "default\n"; } | |
A(std::string a) { std::cout << "string\n"; } | |
}; | |
int main() | |
{ | |
auto s = std::string("ala"); | |
{ | |
A(s); // default | |
// A(s); // error: redeclaration | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment