<<< Template arguments | Index | Template specialization >>> |
Templates arguments can default.
As with function arguments, this is like overloading:
template < typename Type1, typename Type2 = double > class Point { public: // Constructor Point< Type1, Type2 >( Type1 x, Type2 y) : m_x( x ), m_y( y ) { } Type2 distance() { return static_cast< Type2 >( sqrt( m_x * m_x + m_y * m_y ) ); } private: Type1 m_x; Type2 m_y; };//class Point
<<< Template arguments | Index | Template specialization >>> |