template <typename T>
class A{
private:
    T a;
public:
    A(T x) :a(x){}
    void display()
    {
        cout << a << endl;
    }
};

template<>
class A<double>
{
private:
    double a;
public:
    A(double x) :a(x){}
    void display()
    {
        cout << a <<"diao"<<endl;
    }
};

int main()
{
    double a = 3.3;
    A<double> b(a);
    A<int> c(2);
    b.display();
    c.display();
}

 

相关文章:

  • 2022-12-23
  • 2021-09-19
  • 2021-12-31
  • 2021-06-26
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-12-24
  • 2021-12-24
  • 2022-12-23
  • 2021-11-06
相关资源
相似解决方案