By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,911 Members | 1,195 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,911 IT Pros & Developers. It's quick & easy.

Re: Templated friend classes

P: n/a
Victor Bazarov wrote:
I would hope that the syntax

template<class Tclass Derived1: public Base<T>
{
...
template<friend class Derived2<T>;
};

or

template<class Tclass Derived1: public Base<T>
{
...
template friend class Derived2<T>;
};

would work, but IIRC they don't.
Yes, you're right, they don't. At least not with my compiler. Is there a
reason for this? I also tried to use a forward declaration of Derived2
before the definition of Derived1 but obviously, those declaration
aren't allowed for templated classes, either. Again, I don't see why. If
a non-templated class is used in a forward definition, the compiler also
doesn't know what types are in that class.

Ralf
Aug 7 '08 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Ralf Goertz wrote:

I also tried to use a forward declaration of Derived2 before the
definition of Derived1 but obviously, those declaration aren't allowed
for templated classes, either.
That's nonsense. I didn't do it right (I added the ": public Base<T>"
part to the forwarding declaration). Sorry for the noise.

Ralf
Aug 7 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.