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:

  1. unlike k&r c, c++ not support functions implicit return values. main function returns int, , must explicitly declared such.

  2. the class keyword not capitalized, , language case-sensitive. might typo, compiler won't care.

  3. the declaration of vehicle class invalid. class declarations must end semicolon (after closing brace }).

  4. the vehicle class not define constructor accepts integer (or implicitly convertible int), cannot initialize new vehicle object 0.


Comments

Popular posts from this blog

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

c# - Resource not found error -