G
getrakesh
Hi All,
I wanted to know how to declare a friend function which is a member
function of a different class.
Eg:
/* Class which contains the member function to be declared as friend
*/
template <class T, int W>
class A
{
B obj;
public:
void foo(T val); // Function to be declared as a friend.
}
template <class T, int W>
void A<T,W>::foo(val)
{
obj.val = val;
}
/* Class inside which the friend function is to be declared */
template <class U>
class B
{
U val;
public:
friend A<class T, class W>::foo(W val); // Declare friend.
}
I cant seem to get the syntax right. Please let me know.
Thanks
Rakesh
I wanted to know how to declare a friend function which is a member
function of a different class.
Eg:
/* Class which contains the member function to be declared as friend
*/
template <class T, int W>
class A
{
B obj;
public:
void foo(T val); // Function to be declared as a friend.
}
template <class T, int W>
void A<T,W>::foo(val)
{
obj.val = val;
}
/* Class inside which the friend function is to be declared */
template <class U>
class B
{
U val;
public:
friend A<class T, class W>::foo(W val); // Declare friend.
}
I cant seem to get the syntax right. Please let me know.
Thanks
Rakesh