Using friend in templates

Viewed 1817

I am writing a small class, the class is basically a factory for the C class, but I want other classes to be able to access some of the methods.

template<class C>
class CFactory {
public:   
   friend class C;
};

This should make the fields of CFactory available to the class C, but the compiler thinks otherwise.

I'm getting the following two errors using gcc on a mac.

error: using template type parameter 'C' after 'class'

error: friend declaration does not name a class or function

Can anyone tell me what I'm doing wrong and how to get et right?

3 Answers
Related