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

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -