class - Object initialization with 0 -
i wonder, happen if initialize object 0.
for example :
class vehicle { } main() { vehicle v =0; // or vehicle v; v=0; }
assuming c++, code generate compilation error @ least 4 reasons:
unlike k&r c, c++ not support functions implicit return values.
main
function returnsint
, , must explicitly declared such.the
class
keyword not capitalized, , language case-sensitive. might typo, compiler won't care.the declaration of
vehicle
class invalid. class declarations must end semicolon (after closing brace}
).the
vehicle
class not define constructor accepts integer (or implicitly convertibleint
), cannot initialize newvehicle
object0
.
Comments
Post a Comment