i have a link list and i don't know how to write the function
std::size_t Length () const;
template <class T>
OrderedList<T> ?????
i have a link list and i don't know how to write the function
std::size_t Length () const;
template <class T>
OrderedList<T> ?????
I assume you mean how would you go about implementing that function. Well length probably means how many nodes are in your linked list. Start at the head and increment the counter until your next pointer is NULL then return the counter.
"...the results are undefined, and we all know what "undefined" means: it means it works during development, it works during testing, and it blows up in your most important customers' faces." --Scott Meyers
no no i mean for example
public:
OrderedList (const OrderedList<T> & other);
would be this
template <class T>
OrderedList<T> :: OrderedList(const OrderedList
so
public :
std::size_t Length () const;
template <class T>
OrderedList<T> ????? <---what would go here?
Code:template< typename T > std::size_t OrderedList<T>::Length( void ) const { // blah }
how would u call this??
i don't think i did it right...Code:public: friend std::ostream & operator << <T> (std::ostream & outs, const OrderedList<T> & L); template <class T> std::ostream & operator OrderedList<T>:: << <T> (std::ostream & outs, const OrderedList<T> & L)
Just remeber...Originally posted by gqchynaboy
how would u call this??
i don't think i did it right...Code:public: friend std::ostream & operator << <T> (std::ostream & outs, const OrderedList<T> & L); template <class T> std::ostream & operator OrderedList<T>:: << <T> (std::ostream & outs, const OrderedList<T> & L)
So something likeCode:template< typename T > return type class name< T >::Member Function( params )
Code:template< typename T > std::ostream& OrderedList<T>::operator <<( std::ostream &outs, const OrderedList<T> &L ) { // blah! }