Skip to content

Instantly share code, notes, and snippets.

@nyuichi
Created September 7, 2012 08:59
Show Gist options
  • Select an option

  • Save nyuichi/3664490 to your computer and use it in GitHub Desktop.

Select an option

Save nyuichi/3664490 to your computer and use it in GitHub Desktop.
C++の代入のまぎらわしいアレ
int main()
{
// int a(1); という意味だと解釈されてaのコンストラクタが呼ばれる。
int a = 1;
// int b(); b = 1; という意味だと解釈されてbのコンストラクタが呼ばれたあと、bの代入演算子b.operator=(1);が呼ばれる。
int b;
b = 1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment