P
PengYu.UT
Hi,
Suppose I have the following code. I want A::show() behaves differently
for template argument with or without std::complex. But it doesn't
work. Do you know how to do that?
Best wishes,
Peng
#include <iostream>
template <typename Tp>
class A{
public:
A(){};
void show();
};
template <typename Tp>
void A<Tp>::show(){
std::cout << "no complex" << std::endl;
}
template <std::complex<Tp> >
void A<std::complex<Tp> >::show(){
std::cout << "complex" << std::endl;
}
int main(int argc, char *argv[]) {
A<double> a;
A<std::complex<double> > b;
a.show();
b.show();
}
Suppose I have the following code. I want A::show() behaves differently
for template argument with or without std::complex. But it doesn't
work. Do you know how to do that?
Best wishes,
Peng
#include <iostream>
template <typename Tp>
class A{
public:
A(){};
void show();
};
template <typename Tp>
void A<Tp>::show(){
std::cout << "no complex" << std::endl;
}
template <std::complex<Tp> >
void A<std::complex<Tp> >::show(){
std::cout << "complex" << std::endl;
}
int main(int argc, char *argv[]) {
A<double> a;
A<std::complex<double> > b;
a.show();
b.show();
}