S
Samee Zahur
Here's the code ... just wouldn't compile! (not under g++ at least) I'm
just trying to make test<Y>::mem() a friend of test<X> for all Y and X.
I found quite a lot of very similar things googling around, but not
quite what I needed...not feeling lucky I guess
------------------------------Code
start----------------------------------
template <class X> class test
{ X a;
public: test(X b):a(b) {}
friend void fun<>(test); //Compiles fine
template <class Y> void mutatewith(test<Y> b) {a=b.a;}
template <class Y> template <class Z>
friend void test<Y>::mutatewith(test<Z>); //Compiles fine
void mem();
template <class Y> friend void test<Y>::mem(); //ERROR!!
};
template <class X> void fun(test<X> par){par.a=7;}
template class test<double>;
//What if I wanted only the test<Y>::mutatewith(test<X>) to be a friend
of
// test<X> for all Y? Right now, mutatewith has friendship to all
test<Z>
// for all Z !!
-----------------------------code
end----------------------------------------
Samee
just trying to make test<Y>::mem() a friend of test<X> for all Y and X.
I found quite a lot of very similar things googling around, but not
quite what I needed...not feeling lucky I guess
------------------------------Code
start----------------------------------
template <class X> class test
{ X a;
public: test(X b):a(b) {}
friend void fun<>(test); //Compiles fine
template <class Y> void mutatewith(test<Y> b) {a=b.a;}
template <class Y> template <class Z>
friend void test<Y>::mutatewith(test<Z>); //Compiles fine
void mem();
template <class Y> friend void test<Y>::mem(); //ERROR!!
};
template <class X> void fun(test<X> par){par.a=7;}
template class test<double>;
//What if I wanted only the test<Y>::mutatewith(test<X>) to be a friend
of
// test<X> for all Y? Right now, mutatewith has friendship to all
test<Z>
// for all Z !!
-----------------------------code
end----------------------------------------
Samee