#ifndef NUMBER_HPP
#define NUMBER_HPP
template
class Number
{
public:
Number( T value ) : m_value( value )
{
}
T value() const
{
retu
You should do this:
template
Number& operator=( const Number& number )
{
m_value = number.value();
return *this;
}
That is, use T2 in the parameter type, not in the return type!
I would rather use different letter for template parameter:
template
Number& operator=( const Number& number )
{
m_value = number.m_value; //I would also directly access the member variable!
return *this;
}
I think, it is better to use explicit cast, if you want to use class type as template argument and whose constructor has been declared explicit:
m_value = static_cast(number.m_value);
By the way, the other operator= should be implemented as:
Number& operator=(T const & value ) //accept by const reference
{
m_value = value;
return *this; //you've to return!
}