Article View: borland.public.cppbuilder.oodesign
Article #40Re: How to make a template class friend of another class.
From: Thomas Maeder [TeamB]
Date: Thu, 24 Feb 2005 17:52
Date: Thu, 24 Feb 2005 17:52
37 lines
1939 bytes
1939 bytes
Wiljo <invalid@invalid.address> writes:
> I have a class with protected and/or private members that need to be
> accessed by a close relative but template class. Normally one would
> make the second class friend of the first, but when this second class
> is a template, how can I accomplish it then?
Do you want all specializations of B to be friends of A, or just one
particular specialization?
> //#
> //# class A
> //#
> class A
> {
> public:
>
> friend class B; //* This wont work, because class B is template
>
> private:
> void privateFunction();
> };
> //#
> //# template class B
> //#
> template <class XType>
> class B
> {
> public:
> void myFunction( A *ptrA )
> { ptrA->privateFunction(); }
> };
> //#
> //#
What's the point in making B a template?
Technical Details
Message-ID:
<m2r7j5devc.fsf@madbox2.local>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!newshub.sdsu.edu!newsfeed.media.kyoto-u.ac.jp!news-out.nntp.be!propagator2-sterling.newsfeeds.com!news-in.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mailReferences:
<421d9d32$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10db1e,bcb6be07da14baed
X-Google-Attributes: gid10db1e,public
X-Google-Language: ENGLISH,ASCII-7-bit
Newsgroups: borland.public.cppbuilder.oodesign
Subject: Re: How to make a template class friend of another class.
References: <421d9d32$1@newsgroups.borland.com>
From: maeder@glue.ch (Thomas Maeder [TeamB])
Organization: TeamB
X-Face: ":yn4zt^A_dn>6~{YJmu^B\'4w)e:apPM\VC=Dvf&*tASxX9|BYczkFd$xr.$vNSZ[3Uobr p]c4\+\l){!WQI.$]veP({HLd;CDYH?iN
Date: Thu, 24 Feb 2005 18:52:55 +0100
Message-ID: <m2r7j5devc.fsf@madbox2.local>
User-Agent: Gnus/5.1006 (Gnus v5.10.6) XEmacs/21.4 (Jumbo Shrimp, linux)
Cancel-Lock: sha1:rsSTn4455Al5Kv0yNlGwC3g3rYg=
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
NNTP-Posting-Host: 80.218.114.55
X-Trace: newsgroups.borland.com 1109267577 80.218.114.55 (24 Feb 2005 09:52:57 -0800)
Lines: 37
X-Authenticated-User: tmaeder
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!newshub.sdsu.edu!newsfeed.media.kyoto-u.ac.jp!news-out.nntp.be!propagator2-sterling.newsfeeds.com!news-in.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail