I have the same implementation for 2 methods, they both insert argument to a text file.
void WriteToFile( double content) //for double
{
streamFile << content;
streamFile << flush;
}
void WriteToFile( int content) //for integer
{
streamFile << content;
streamFile << flush;
}
The implementation is same, therefore I merge them to a template method:
template < class T>
void WriteToFile(T content)
{
streamFile << content;
streamFile << flush;
}
But the WriteToFile()
method should be virtual.
How can I deal with it?