Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

friend template classes

This topic is 6475 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Im using templates to make a generic linked list i have one class template called ListElement which contains data the data and and the pointer to the next ListElement, and a template class called List which contains an object of type ListElement. I want the data in ListElement to be private, so how do i tell that List is a friend of ListElement?

Share this post


Link to post
Share on other sites
Advertisement
Well, this works:

template< class T > class foo_list;

template< class T > class foo {
friend foo_list;
};

template< class T > class foo_list (

};


However what I would do would be to declare ListElement (foo, in the above example) as an inner class of List, ie:


template< class T >
class List
{
template< class T >
class ListElement
{
friend List;
};
};


Edited by - Kensai on August 29, 2000 3:36:28 PM

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!