Freind class function inaccessible because of template

So function from class A is not available to class B because B has a template type and A can't recognize which type to be friended. Does anyone know what is the problem? Thanks. Here is the code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
class A {

    template<typename N>
    friend class B<N>;

    void foo() {
    }

};

template<typename T>
class B {

public:

    void foo2(A a) {
        a.foo(); //error says "private 'A::foo()' is inaccessible"
    }

};
Last edited on
Remove <N>

1
2
template<typename N>
friend class B<N>;
Topic archived. No new replies allowed.