相关代码 |
|
#include template class Sample { T n; public: Sample() {} Sample(T i) { n=i; } Sample & operator+(const Sample &); void disp() { cout }; template Sample & Sample::operator+(const Sample &s) { static Sample temp; temp.n=n+s.n; return temp; } void main() { Sample s1(10),s2(20),s3; s3=s1+s2; s3.disp(); }
相关资源 |
|