By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,190 Members | 833 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,190 IT Pros & Developers. It's quick & easy.

friend declaration for template class

P: n/a
Hi, I have a class like so...

template<class XV, class T> class Foo {
Bar<T>* b;
};

and another class
template<class T> class Bar {
public:
friend template<class XV, class T> class Foo<XV,T>; // wrong
friend class Foo;
// wrong
friend class Foo<XV,T> //
wrong
};

so what is the correct way to give Foo access to Bar's members? Thanks..

Smith
Jul 19 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
"john smith" <as**@asdf123asdf.net> wrote...
Hi, I have a class like so...

template<class XV, class T> class Foo {
Bar<T>* b;
};

and another class
template<class T> class Bar {
public:
friend template<class XV, class T> class Foo<XV,T>; // wrong
friend class Foo;
// wrong
friend class Foo<XV,T> // wrong
};

so what is the correct way to give Foo access to Bar's members? Thanks..


template<class XV, class U> friend class Foo;

Victor
Jul 19 '05 #2

P: n/a
"john smith" <as**@asdf123asdf.net> wrote...
Hi, I have a class like so...

template<class XV, class T> class Foo {
Bar<T>* b;
};

and another class
template<class T> class Bar {
public:
friend template<class XV, class T> class Foo<XV,T>; // wrong
friend class Foo;
// wrong
friend class Foo<XV,T> // wrong
};

so what is the correct way to give Foo access to Bar's members? Thanks..


template<class XV, class U> friend class Foo;

Victor
Jul 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.