16.8k views
5 votes
when a member function is defined outside of the class declaration, the function name must be qualified with the .

1 Answer

5 votes

Answer: When a member function is defined outside of the class declaration, the function name must be qualified with the class name and the scope resolution operator ::. This is called the "namespace qualification" or "class qualification" syntax.

For example, if you have a class named MyClass with a member function myFunction, and you define the function outside of the class declaration, you would write:

class MyClass {

public:

void myFunction(); // declaration

};

void MyClass::myFunction() {

// definition

}

In the definition of myFunction, the function name is qualified with the class name MyClass and the scope resolution operator ::. This tells the compiler that myFunction is a member function of MyClass.

So, the correct statement is:

When a member function is defined outside of the class declaration, the function name must be qualified with the class name and the scope resolution operator ::.

User Tomas Karban
by
8.2k points

No related questions found