DEV Community

stfark
stfark

Posted on • Edited on

Global and Local Items, C++

Confused: Two files, one works, one doesn't, difference is that the declaration "vector string Name;" is placed in two locations, one preceding the "int main()" statement and one within the function. The compiler issues an error for the one that precedes the "int main()" function that the command "getline" is not a valid name. I thought that in C++, one could declare the variable either globally or local to the function and would still be interpreted, in a different manner of course, but not issue and error the the command is not valid in one case, totally confused and any help will be appreciated, Sid Kraft.

Top comments (0)