Jump to content
  • Advertisement


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


Template question

This topic is 5922 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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


Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!