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?
Ise’s response is correct — Comeau’s FAQ contains a question concerning this issue in more detail.
However, perhaps you can try an extra template indirection that might work? Something like this:
This seems to only work with gcc 4.5.x however so I wouldn’t rely on it.