• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Help with Friend Fucnction and a Class template

imported_vr6

Platinum Member
How i do go about declaring a friend function, in this case an overloaded operator<<, of a template class? I want to declare one so that any classes created with the class template all use this same operator<<.
Heres what i have in the .H file

template< class T >
class WhatEver
{

//---------------------------------------------------------
//Method: operator<<
//Precondition: a WhatEver object exists
//PostCondition:
// attributes of a WhatEverObject is outtputted to the screen
//--------------------------------------------------------
friend ostream& operator<< ( ostream& out, const WhatEver& object );


public:
//

private: //

};

and in the .C file

//---------------------------------------------------------
//Method: operator<<
//Precondition: a whatever object exists
//PostCondition:
// attributes of a whatever object is outtputted to the screen
//--------------------------------------------------------
ostream& operator<< ( ostream& out, const Whatever& object )
{
//Various Out Statements.

return out;
}



 
Back
Top