c++ - What is the reason for "declaration does not declare anything" error? -
if have class called 'rock', , :-
int main() { rock; }
why "declaration not declare anything" error ?
shouldn't call default constructor , create object @ moment?
ofcourse won't able use object , destroyed when go out of scope of function, why not creating @ all?
in other programming languages java, variables not compulsory. can new rock() , fine.
i know isn't of use want clear confusion.
rock
name of class. there no variable name declared. call constructor/create object, need declare name of variable: rock r;
this creates object on stack destroyed when goes out of scope
Comments
Post a Comment