www.digitalmars.com         C & C++   DMDScript  
Archives

D Programming
digitalmars.D
digitalmars.D.bugs
digitalmars.D.dtl
digitalmars.D.ide
digitalmars.D.dwt
digitalmars.D.announce
digitalmars.D.learn
digitalmars.D.debugger
D.gnu
D

C/C++ Programming
c++
c++.announce
c++.atl
c++.beta
c++.chat
c++.command-line
c++.dos
c++.dos.16-bits
c++.dos.32-bits
c++.idde
c++.mfc
c++.rtl
c++.stl
c++.stl.hp
c++.stl.port
c++.stl.sgi
c++.stlsoft
c++.windows
c++.windows.16-bits
c++.windows.32-bits
c++.wxwindows

digitalmars.empire
digitalmars.DMDScript
electronics



c++.beta - template friend class

template<class T> struct A;

template<class T>
struct B
{
  template<class Y> friend class A;

 private:
  int i;
};

template<class T> struct A
{
  A()
  { }

  template<class Y>
  A(B<Y> &b)
  {
    b.i = 0;
    // Error: member 'B<int >::i' of class 'B<int >' is not accessible
  }
};


int main()
{
  A<int> a;
  B<int> b;

  A<int> a2(b);

  return 0;
}


Extracted from Boost's smart_ptr library.


bye, Christof

-- 
http://cmeerw.org                                 JID: cmeerw jabber.at
mailto cmeerw at web.de

...and what have you contributed to the Net?
Jun 28 2003