Declaring Local Object in C++ -


this question has answer here:

one of question on c++ faq discusses correct way declare local object within function: http://www.parashift.com/c++-faq/fn-decl-vs-obj-instantiation.html

given example faq:

class bar {  public:    bar(); };  class foo { public:   foo(bar const& b);   void blah(); };  void yourcode() {   foo x(bar());  // error      } 

in vs2012, error foo x(bar (__cdecl *)(void))': prototyped function not called (was variable definition intended?)

could explain me why this declaration gives error ?(c++ faq explanation vague). foo , bar both visible within body of yourcode(), , foo x(bar()); way declare object of type foo.

as c++'s vexing parse, can do:

foo x((bar())); 

or

foo x = bar(); 

the details reviewed in parashift link provided in question.
note though, second example break if foo copy constructor made explicit.