填空题
【13】
允许用户为类定义一种模式,使得类中的某些数据成员及某些成员函数的返回值能取任意类型。
【参考答案】
类模板
点击查看答案&解析
<上一题
目录
下一题>
热门
试题
填空题
有以下程序: #include <iostream> using namespace std; class Base public: Base() x=0; int x; ; class Derivedl: virtual public Base public: Derived1() x=10; ; class Derived2: virtual public Base public: Derived2() x=20; ; class Derived: public Derived1,protected Derived2 ; int main() Derived obj; cout<<obj.x<<endl; return 0; 该程序运行后的输出结果是 【14】 。
点击查看答案&解析
填空题
下面是复数类complex的定义,其中作为友元函数重载的运算符“--”的功能是将参数对象的实部减1,然后返回对该对象的引用;请补充完整。 class complex private: int real; iht imag; public: complex(int r=0,int i=0):real(r),imag(i) void show() cout<<real<<(imag<0 - : + )<<imag<<’i’; 【15】 ; ; complex& operator -- (complex &c) c.real--; return c;
点击查看答案&解析
相关试题
有如下程序: #include <iostream> u...
下面程序的运行结果是 【9】 。 #incl...
以下程序运行后的输出结果是 【10】 。...
下面程序的输出结果是 【8】 。 #incl...
在下面横线上填上适当的语句,完成程序。 ...