What is the correct syntax of accessing a static member of a class in C++ ?
class Sample { public: static int val; }
class Sample { public: static int val; }
The correct answer is B) Sample::val
In C++, to access a static member of a class, you use the scope resolution operator :: along with the class name followed by the static member's name.