B
ben
template <typename T>
class A
{
friend class T; // error, but why?
};
class A
{
friend class T; // error, but why?
};
ben said:template <typename T>
class A
{
friend class T; // error, but why?
};
John Carson said:Because the C++ standard says so.
http://groups-beta.google.com/group/comp.lang.c++/browse_frm/thread/fa2f0778df
c62abb/918a87917621b61e?q=May+a+template+argument+be+friends+of+the+template+c
lass+Malte+Starostik&rnum=1&hl=en#918a87917621b61e
Presumably allowing it to compile creates problems in some cases (or makes
the compiler harder to write), though I can't help with the details on this.
It may be noted that for some T the friend declaration would not make sense,
e.g., friend class int; This may (or may not) have some relevance.
Though there's a good chance that this will change in C++0X:
ben said:, which will be 10 years away???
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.