How to make Template functions friends to a class

M

madhukar_bm

Can we declare a template function as a friend to a class, if yes
please give me the syntax.Thanks in advance
rgrds
Madhukar
 
G

Gianni Mariani

madhukar_bm said:
Can we declare a template function as a friend to a class, if yes
please give me the syntax.Thanks in advance
rgrds
Madhukar

Yes.

class foo
{
public:
template <typename x> friend class x;
int y;
};


template <typename x> class x
{
public:
void func( foo * x )
{
x->y =2;
}
};


I didn't compiler the code above but it *should* work.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top