阅读下面程序: #include <iostream.h> template <class T> class TAdd { private: T x, y; public: TAdd(T a, T b) { x=a; y=b; } T add() { re

admin2013-05-30  20

问题 阅读下面程序:
#include <iostream.h>
template <class T>
class TAdd
{
private:
T x, y;
public:
TAdd(T a, T b)
{
x=a;
y=b;
}
T add()
{
return x +y;
}
};
void main( )
{
TAdd<int>a(5,6);
TAdd<double>b(2.4,5.8);
cout<<"s1 ="<<A. add()<<",";
cout<<"s2="<<B, add()<<end1;
}
写出该程序的运行结果:【  】。

选项

答案s1=11,s2=8.2

解析
转载请注明原文地址:https://kaotiyun.com/show/OTNp777K
0

最新回复(0)