My professor gave us this piece of code to study to better understand how class templates work in C++ but I'm confused on what the second line means. I put two asterisks (**) next to the statement I'd like more clarification on.
template<typename T>
Pair<T>::Pair(const T& firstVal, const T& secondVal) //**
{
first = firstVal;
second = secondVal;
}
This is the Pair
class template :
template<typename T>
class Pair
{
public:
Pair();
Pair(const T& firstVal, const T& secondVal);
void setFirst(const T& newVal);
void setSecond(const T& newVal);
T getFirst() const;
T getSecond() const;
~Pair(){}
private:
T first, second;
};
What I'm confused about is why she's treating the constructor as a function and defining it as the class has no member functions with the name "Pair" apart from the constructor? I'm sure I'm misunderstanding something about constructors and functions and if someone could help I'd greatly appreciate it, thank you!