Topic: Template is my friend


Author: tmackenz@newsserver.trl.oz.au (Tim MacKenzie)
Date: 19 Sep 1994 17:05:51 +1000
Raw View
If I want to declare a templated class to be a friend of another class
what should be done? For example, is the following code correct?

class N {
private:
 friend class T;  // I want all T<foo>'s to be my friend.
 N(); // I have a private constructor so only my friends can touch me.
};

template<class G> class T
{
public:
 N instanc;
};

T<int> a;  // To make the compiler look inside the template...

Different compilers accept/reject this code.
Is the use of "class T" to represent all T<foo>'s correct?
--
-Tim MacKenzie (t.mackenzie@trl.oz.au)