Which of the following is used to define the members of a class externally in…
2023
Which of the following is used to define the members of a class externally in C++?
- A.
:
- B.
::
- C.
#
- D.
More than one of the above
- E.
None of the above
Attempted by 167 students.
Show answer & explanation
Correct answer: B
In C++, the scope resolution operator (::) is used to define class member functions outside the class definition. This allows the function body to be written separately from the class declaration. The colon (:) is used in constructors for member initialization, not for defining members externally. The hash symbol (#) is used for preprocessor directives like #include and #define, not for defining class members. Therefore, only the scope resolution operator is used for external definition of class members.