// Foo.cpp
int whatScopeAmI = 0;
Foo::Foo() {
// source code
}
What scope does the variable whatScopeAmI have?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It’s a global, available everywhere in the program.
If a different translation unit had a
extern int whatScopeAmI;declaration, it would refer to the same variable.If the variable was declared as
static int whatScopeAmI = 0;it would have internal linkeage, and would be available only in the current translation unit.