This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
declaration of friend template class
- To: gcc-bugs at gcc dot gnu dot org
- Subject: declaration of friend template class
- From: Alexander Zvyagin <zvyagin at gams dot ihep dot su>
- Date: Sun, 15 Aug 1999 12:56:04 +0400 (MSD)
Dear GCC developers!
What is wrong in the code attached below? It seems gcc-2.95 can not
handle friend template classes. Or may be I use wrong syntax?
With best wishes,
Alexander Zvyagin.
--- File a.c --------------------------------
template <class T> class B; // forward declaration.
class A
{
private: int a; // private varaible.
friend class B <class T>; // is it correct friend definition?
};
template <class T>
class B
{
private: A a;
public: B() {a.a=1;} // access to private variable.
};
main() {B<int> b;}
--- EOF -------------------------------------
$ g++ -c a.c
a.c: In method `B<int>::B()':
a.c:16: instantiated from here
a.c:5: `int A::a' is private
a.c:13: within this context