template specialization in member function

J

John

I have a class

class x{

public:

template<typename X>
friend X func(X a){
....
}

// I would also want to write the following

template< >
friend double func<double>(double a){
....
}


}


Can someone help on what i am doing wrong?

Thanks,
--j
 
K

Karthik Kumar

John said:
I have a class

class x{

public:

template<typename X>
friend X func(X a){
...
}

Post a compilable code here to clarify
your question.
// I would also want to write the following

template< >
friend double func<double>(double a){

'friend' appears in the declaration of a function,
and not in the definition of the function.

Also this friend function does not seems to take
any user-defined data types. It just takes a 'double'.
'friend' functions are used to access *all the members*
of a given class.

While there is nothing wrong with this as far as the
grammar of the language is concerned, you may need
to revisit this anyway, if this is what you intend to
write.
...
}


}


Can someone help on what i am doing wrong?

Post code.
 

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,770
Messages
2,569,583
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top