142k views
2 votes
Which XXX is used for the member function Display() definition in the following code?

class Studenti public: void SetName(string studentName); void SetGrade(int studentGrade); void Display(); private: string name; int grade; }; XXX { } int main() { Student stul; }

a. Display
b. void Display
c. void Display::Student)
d. void Student::Display

1 Answer

1 vote

Final answer:

The correct identifier for defining the member function Display() outside the class is Option D. 'void Student::Display'. The scope resolution operator (::) connects the function name to its class.

Step-by-step explanation:

The correct identifier to use for the member function Display() definition in the given Student class is option d: void Student::Display. When defining a member function outside of the class declaration in C++, you should prepend the class name to the function name with the scope resolution operator ::. This signifies that the function Display is a member of the Student class. Hence the proper member function definition would look like this:

void Student::Display() {
// Function definition here
}

This syntax ensures that the Display function is associated with the Student class.

User Pomkine
by
8.2k points