How do you call this??

This is a discussion on How do you call this?? within the C++ Programming forums, part of the General Programming Boards category; i have a link list and i don't know how to write the function std::size_t Length () const; template <class ...

  1. #1
    Registered User
    Join Date
    Apr 2003
    Posts
    82

    How do you call this??

    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> ?????

  2. #2
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571
    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

  3. #3
    Registered User
    Join Date
    Apr 2003
    Posts
    82

    Re: How do you call this??

    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?

  4. #4
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571
    Code:
    template< typename T >
    std::size_t OrderedList<T>::Length( void ) const
    {
      // blah
    }

  5. #5
    Registered User
    Join Date
    Apr 2003
    Posts
    82
    how would u call this??
    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)
    i don't think i did it right...

  6. #6
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571
    Originally posted by gqchynaboy
    how would u call this??
    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)
    i don't think i did it right...
    Just remeber...

    Code:
    template< typename T >
    return type     class name< T >::Member Function( params )
    So something like
    Code:
    template< typename T >
    std::ostream& OrderedList<T>::operator <<( std::ostream &outs, const OrderedList<T> &L )
    {
      // blah!
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. minix system call pls help for project
    By porvas in forum Linux Programming
    Replies: 2
    Last Post: 06-14-2009, 02:40 AM
  2. Error C2664 - Trying to call an external Dll
    By jamez05 in forum C++ Programming
    Replies: 3
    Last Post: 08-08-2006, 06:07 AM
  3. Class won't call
    By Aalmaron in forum C++ Programming
    Replies: 3
    Last Post: 04-13-2006, 04:57 PM
  4. Iterative Tree Traversal using a stack
    By BigDaddyDrew in forum C++ Programming
    Replies: 7
    Last Post: 03-10-2003, 04:44 PM
  5. call by reference and a call by value
    By IceCold in forum C Programming
    Replies: 4
    Last Post: 09-08-2001, 05:06 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21