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.
mainfunction returnsint, , must explicitly declared such.the
classkeyword not capitalized, , language case-sensitive. might typo, compiler won't care.the declaration of
vehicleclass invalid. class declarations must end semicolon (after closing brace}).the
vehicleclass not define constructor accepts integer (or implicitly convertibleint), cannot initialize newvehicleobject0.
Comments
Post a Comment