[LC++]Template classes and Friends

Charles Randle charlesrandle at yahoo.com
Wed Sep 11 18:41:05 UTC 2002


Hi All ,

I have say two classes :

template <class TYP1,class TYP2>
class A {
.....
};

and 

template <class TYP2>
class B {
........
};

Is there any way I can make class A a friend of class
B only when the template parameter TYP2 of A is the
same as TYP2 of class B in instantiation ?
For example :
"A<long,int> firstObject;" and "B<int> secondObject;"
: firstObject is a friend of secondObject.

BUT....
"A<long,char *> thirdObject;" and "B<float>
fourthObject;" : thirdObject is NOT a friend of
fourthObject.

Can this be effected , and if so how ?

Best Regards,
Charles Randle

__________________________________________________
Do You Yahoo!?
Yahoo! Finance - Get real-time stock quotes
http://finance.yahoo.com




More information about the tuxCPProgramming mailing list