Answer the question
In order to leave comments, you need to log in
How to overload a function inside a template?
template <typename T> class matrix
{
private:
T **m_container;
int m_rows;
int m_columns;
void in(int i, int j)
{
cin >> m_container[i][j];
}
template <char*> void in(int i, int j)
{
m_container[i][j] = new char [100];
cin.getline(m_container[i][j], 100);
}
Answer the question
In order to leave comments, you need to log in
From what I understand, you need to specialize in for matrix<char*>:
template <typename T> class matrix
{
private:
T **m_container;
int m_rows;
int m_columns;
void in(int i, int j)
{
cin >> m_container[i][j];
}
};
template<>
void matrix<char*>::in(int i, int j)
{
m_container[i][j] = new char [100];
cin.getline(m_container[i][j], 100);
}][j], 100);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question