Friend and Templates


[ Follow Ups ] [ Post Followup ] [ CS2704 Web Discussion Board ] [ FAQ ]

Posted by Juan Romero Jr. on March 22, 2001 at 01:47:14:

I cant remember if this topic was discussed in class or not, but I know we talked about friend functions, and we talked about templates, but what about friend functions inside templates?? Is this not allowed for this project?

If it is, I would like to direct you all to pages 854-855 of the Stroustrop book on syntax, and how to use friend functions with templates. This is good for when you want to overload those operators that can't be used as class members (like >> and <<).

I stumbled onto this in my code when I used a friend function with my template (and the compiler got mad at me when I coded the function header like the example given in the Operator overloading notes), and when I referred to the book and fixed my code, everything ran smoothly.

My 2 cents


Follow Ups:



Post a Followup

Name:
E-Mail:

Subject:

Comments:

Optional Link URL:
Link Title:
Optional Image URL:


[ Follow Ups ] [ Post Followup ] [ CS2704 Web Discussion Board ] [ FAQ ]