friend declaration for template class

Discussion in 'C++' started by john smith, Aug 10, 2003.

  1. john smith

    john smith Guest

    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
     
    john smith, Aug 10, 2003
    #1
    1. Advertising

  2. "john smith" <> 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
     
    Victor Bazarov, Aug 10, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Yu Lianqing
    Replies:
    1
    Views:
    646
    Leor Zolman
    Apr 4, 2004
  2. Replies:
    4
    Views:
    6,963
    Ian Collins
    Jan 26, 2007
  3. Replies:
    2
    Views:
    514
    Rolf Magnus
    Jan 26, 2007
  4. A L
    Replies:
    1
    Views:
    516
    Alf P. Steinbach /Usenet
    Aug 25, 2010
  5. Peter
    Replies:
    2
    Views:
    287
    Öö Tiib
    Jun 6, 2013
Loading...

Share This Page