In C, one can of course declare and define functions. And this interacts with default constructor calls from C++ to yield the most vexing parse problem. Say I want to declare a function foo
, define a function bar
and create an instance t
, I might mistakenly write this (having Python or Java in mind):
T foo();
T bar() {
T t();
}
This will not do what I want, it will declare a function t
with no arguments (or perhaps arbitrary many ones as there is no void
written in there, not sure) and return type T
. I would get a T
instance with T t;
.
Why is this syntax even allowed? What is the point of declaring a function just within a function? The linker will have to resolve this at link time anyway, and then one could just declare that function in the file scope. Is there some edge case that I am missing?