ExamVeda
Login
Home
Object Oriented Programming Using C Plus Plus
?

To use a template class member function, use the ________ with the instantiation

Answer & Solution
Correct Answer: Option B
Let's discuss the solution. Join the discussion
Examveda
Question posted by Examveda
Community

Join the Discussion

1 Comment
Arvind Maurya
Arvind Maurya 2 years ago
To use a template class member function, you typically need to use the scope resolution operator to specify which template specialization you are referring to.

So the correct answer is:

A. scope resolution operator

Explanation:

When you have a template class, you often need to specify the type parameters to instantiate the template class. Once instantiated, you can use the scope resolution operator (::) to refer to its member functions. Here’s an example:

template
class MyClass {
public:
void myFunction();
};

// Define the member function outside the class definition
template
void MyClass::myFunction() {
// Function implementation
}

// Usage
int main() {
MyClass obj; // Instantiation of the template class with int
obj.myFunction(); // Call to the member function
}