I met this C++ question:
Question: Is the following a definition or a declaration?
Foo f(Bar());
Answer: It is possibly either a declaration of a function that takes type Bar and returns type Foo or it is a definition of f
as a type Foo
, which has a constructor that takes type Bar. The problem is the syntax for both is identical so to resolve this problem the C++ standard states that a compiler must prefer function declarations to object definitions where it is unable to make a distinction.
-- I don't understand why it can be "a declaration of a function that takes type Bar and returns type Foo"? how come a parenthesis "()" appear in parameter list?