This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

declaration of friend template class


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



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]