Skip to content

Instantly share code, notes, and snippets.

@hryniuk
Created March 29, 2017 09:51
Show Gist options
  • Save hryniuk/f1a1a5ce0761e91250d388f5df4672a3 to your computer and use it in GitHub Desktop.
Save hryniuk/f1a1a5ce0761e91250d388f5df4672a3 to your computer and use it in GitHub Desktop.
Constructor glitch
#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