8.17

来源:互联网 发布:联想售后系统优化 编辑:程序博客网 时间:2024/05/21 17:41
#include<iostream>  using namespace std;  template<typename G>        class Sum{                     public:      Sum(T a,T b,T c)      { x=a; y=b; z=c;  }     G add()      { return x+y+z;  }    private:  G x,y,z;  };  int main()  { Sum<int> s1(3,6,9);              Sum<double> s2(11.11,22.22,33.33);     cout<<"三个整数的和为:"<<s1. add()<<endl;    cout<<"三个双精度数的和为:"<<s2.add()<<endl;    return 0;  

0 0