BO> C++ assumes a void return list if nothign is specified
No it doesn't. "Common" C++ assumes an *int* return type if none is
specified in a function declaration. This is because it evolved from C,
which did the same thing. In Standard C++, such code is ill-formed. All
function declarations must include a return type in Standard C++.
BO> an exception to this is class constructors which always has a
BO> return value of a pointer to an instance to the class in question.
If your C++ compiler allows you to give a constructor declaration a return
type, then your C++ compiler is seriously broken. Not even Common C++ allows
that. The return type of a constructor may not be specified in Standard C++.
BO> C++ assumes a void parameter list if nothing is written inside the
BO> brackets.
As I said before, this is backwards. It is C that assumes an empty parameter
list when it encounters the single keyword "void". C++, which does not allow
K&R-style function declarations, and so can recognise a function declaration
with nothing between the brackets as a function that has an empty parameter
list, supports this "void kludge" merely for compatibility with C.
¯ JdeBP ®
--- FleetStreet 1.19 NR
---------------
* Origin: JdeBP's point, using Squish (2:440/4.3)
|