C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Friendly Templates

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ Language (Moderated)
View previous topic :: View next topic  
Author Message
Kevin Anthoney
Guest





PostPosted: Thu Oct 28, 2004 1:50 pm    Post subject: Friendly Templates Reply with quote



Is there any way to make all classes of a given template friendly with each other?

For example:

template< int n >
class T
{
private:
int a;

public:
T( int i = 0 );
template< int m > T( const T< m >& x );
};

I want classes of type T< n > to be able to access the private data of T< m >,
but can't find the right syntax.

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
Back to top
Victor Bazarov
Guest





PostPosted: Fri Oct 29, 2004 2:07 am    Post subject: Re: Friendly Templates Reply with quote



Kevin Anthoney wrote:
Quote:
Is there any way to make all classes of a given template friendly with each
other?

For example:

template< int n
class T
{
private:
int a;

public:
T( int i = 0 );
template< int m > T( const T< m >& x );
};

I want classes of type T< n > to be able to access the private data of T< m
,
but can't find the right syntax.

Add anywhere inside the T definition:

template
V

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

Back to top
Jonathan Turkanis
Guest





PostPosted: Fri Oct 29, 2004 2:33 pm    Post subject: Re: Friendly Templates Reply with quote




"Kevin Anthoney" <kevin_anthoney (AT) hotmail (DOT) com> wrote

Quote:
Is there any way to make all classes of a given template friendly with each
other?

For example:

template< int n
class T
{
private:
int a;

template friend class T;

Quote:

public:
T( int i = 0 );
template< int m > T( const T< m >& x );
};


Jonathan



[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ Language (Moderated) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.