Simpletron s();
This is a classic case of "annoying parsing"; for the compiler, you do not create an s variable of type Simpletron , but you declare a function named s without taking any parameters and returning a Simpletron object.
This is due to the fact that this expression can be interpreted as a declaration of a function, or as a declaration of a variable; since there is a simple alternative to declaring a variable (namely, just omit the brackets), standard mandates interpret this as a function declaration.
This completes the compilation step without problems (the compiler should not have a definition of all methods, just a declaration), and probably the linker does not give any error, since the Simpletron instance is actually, so you never need to look for the constructor definition (although I donβt think that it is guaranteed to not give errors, especially a careful compiler / linker pair should be able to give you an error for a missing constructor).
Matteo italia
source share