Multiple choice

Which of the following operators is used to define the class methods, physically outside the class?

    • (Asterisk)
  1. ? (Question mark)

  2. : (Colon)

  3. :: (Scope resolution operator)

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

The (::) Scope Resolution Operator is used in C++ to define a class method, outside the class. Although the method is defined outside the class, it is still a member of the class. The scope resolution operator is used for some other purposes also. To define a method outside the class, we can use the code as given in the following example : class sample { int a=10; public:    void show(); }; void sample :: show() // defining the method outside the class. { cout<