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;
}
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;
}