Archived

This topic is now archived and is closed to further replies.

rhide

Template question

Recommended Posts

Im reading "Teach yourself C++ in 21 days" at the moment, and I have reached the 19th day. There is a code piece I really cant understand in that chapter:
template <class T>
bool operator== (const T& lhs, const T& rhs)
{
  //I dont understand this if-statement ...

  if (lhs.CellsInLinkedList() != rhs.CellsInLinkedList())
    return 0;

  ... // more code


  return 1; // if nothing went wrong

}
This operator is declared as friend to a linked list named LinkedList. This means LinkedList would give access to the class functions, and T alone should give access to the parametirized type (int, char, cAnimal, whatever). What I dont understand is how in the world "const T& lhs" and "const T& rhs" can give access to the entire classes ??? Please help me straighten this out! [edited by - rhide on July 28, 2003 8:49:11 PM]

Share this post


Link to post
Share on other sites
Forget about my question, It was 03:30 PM (local time) when i posted this message, but i realized my wrong not very long time aftewards.

The parameter was a function (LinkedListNode), lol

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Just curious, how many days did it take for you to reach until the 19th day of the book? :-)

I''m from sweden too

Albert

Share this post


Link to post
Share on other sites