X
xuatla
The following is just a sample code to demostrate my question:
-----------
template <typename T>
class C
{
public:
friend void f1(double i=2) { std::cout << i; } ;
};
-----------
compile result:
test1.cpp: In instantiation of `void f1(double)':
test1.cpp:95: instantiated from here
test1.cpp:88: error: default argument given for parameter 1 of `void
f1(double)'
test1.cpp:88: error: after previous specification in `void f1(double)'
------------
If I don't use template or I remove the default argument in f1, then no
problem occurs. But with both of them it won't work.
Anyone know the reason for this problem?
Thanks a lot in advance.
X
-----------
template <typename T>
class C
{
public:
friend void f1(double i=2) { std::cout << i; } ;
};
-----------
compile result:
test1.cpp: In instantiation of `void f1(double)':
test1.cpp:95: instantiated from here
test1.cpp:88: error: default argument given for parameter 1 of `void
f1(double)'
test1.cpp:88: error: after previous specification in `void f1(double)'
------------
If I don't use template or I remove the default argument in f1, then no
problem occurs. But with both of them it won't work.
Anyone know the reason for this problem?
Thanks a lot in advance.
X