<<< More template internals | Index | Default constructor behavior of C++ types >>> |
Sometimes, you want to construct an object of type ValueT with default constructor behavior:
template < typename ValueT >
ValueT Stack< ValueT >::pop()
{
if ( is_empty() ) {
cerr << "Pop failed, stack is empty" << endl;
return ValueT();
}
return m_ptr_data[ --m_top ];
}
Happily, this works fine when ValueT is a native C++ type!
<<< More template internals | Index | Default constructor behavior of C++ types >>> |