2011.01.13 - most vexing parse

among many pitfalls in C++ there is so called “most vexing parse”. as the name suggests, it is vexing. especially that it is a heritage from C.

consider given code:

#include <iostream>
struct S 
{
  S(){ std::cout<<"S()\n"; }
  S(const S&){ std::cout<<"S(cpctor)\n"; }
};
 
int main(void)
{
  S s( S() );
  return 0;
}

what will show on the screen? if your answer wasn't “nothing”, that read on on explanation on the most vexing parse1)

1)
many thanks to Strzygolak for sharing this link
blog/2011/01/13.txt · Last modified: 2013/05/17 19:08 (external edit)
Back to top
Valid CSS Driven by DokuWiki Recent changes RSS feed Valid XHTML 1.0