关于构造函数初始化
template <class elemType> class Example2 {
public:
explicit Example2( elemType val = 0 )
: _val( val ){}
bool min( elemType value ) { return _val < value; }
void value( elemType new_val ) { _val = new_val; }
void print( ostream &os ) { os << _val; }
private:
elemType _val;
};
template<class elemType>
ostream& operator<< ( ostream &os, const Example2<elemType> &ex )
{ ex.print( os ); return os; }
Example2< string > exs( "Walden" ); 这一句为什么能初始化exs的值 为Walden