Complete the code to access the global variable inside the function.
int x = 10; void func() { int x = 5; printf("%d", [1]); }
The scope resolution operator :: accesses the global variable x inside the function.
Complete the code to access the class static member variable using scope resolution.
class MyClass { public: static int count; }; int main() { MyClass::[1] = 5; return 0; }
The static member variable is accessed using the class name and scope resolution operator followed by the variable name.
Fix the error in accessing the nested namespace variable using scope resolution.
namespace Outer {
namespace Inner {
int value = 42;
}
}
int main() {
int x = [1];
return 0;
}Namespaces are accessed using the scope resolution operator :: between each namespace and variable.
Fill both blanks to correctly define and access a static member function using scope resolution.
class Calculator { public: static int [1]() { return 100; } }; int main() { int result = Calculator::[2](); return 0; }
The static member function is declared as getValue without parentheses in the definition and accessed with parentheses when called.
Fill all three blanks to correctly define and access a variable inside nested classes using scope resolution.
class Outer { public: class Inner { public: static int [1]; }; }; int Outer::Inner::[2] = 50; int main() { int val = Outer::Inner::[3]; return 0; }
The static variable data is declared inside the nested class, defined outside with full scope, and accessed using scope resolution.
