Making an unknown friend
template
class List
{
protected:
class a {
int x;
int y;
private:
friend class b;
The code is ill-formed and Comeau rejects it giving the following error
error: invalid redeclaration of type name "b" (declared at
line 11)
I think this is a bug in g++. Intel C++ rejects it too. You can fix the code by defining class B
above A
.
template class b {
int z;
U y;
};
class a {
int x;
int y;
private:
friend class b;
};