问答题
在下面横线处填上正确的内容,完成类的定义。
class Base
int x;
static const int b;
public:
Base( int, int);
const int &a;
};
______ b=15;
Base::Base(int i, int j): ______{}
【参考答案】
const int Base:: x(i), a(j)或x(j), a(i)
点击查看答案
<上一题
目录
下一题>
热门
试题
问答题
#include < iostream >using namespace std;class Date;class Time{ public:Time ( int h, int m, int s){ hour = h; minute = m; sec = s; }void show(Date& d);private:int hour, minute, sec;};class Date{ public:Date( int m, int d, int y){ month = m; day = d; year = y; }void Time::show( Date &);private:int month, day, year;};void Time:: show( Date& d){ cout << d.month << - << d.day << - << d.year << endl;cout << hour << : << minute << : << sec << endl;}void main (){ Time t1 (9,23,50);Date d1 (12,20,2010);t1.show( d1 );}
点击查看答案
问答题
#include < iostream.h >class X{ public:int x;public:X( int x){ cout << this - > x = x << endl; }X( X& t){x=t.x;cout << t.x << endl;}void fun(X);};void fun(X t){ cout << t.x << endl; }void main (){ fun(X(10));}
点击查看答案
相关试题
已知交通工具类定义如下。要求:(1)实现...
#include < iostream.h >class Bas...
#include < iostream.h >class Com...
程序的输出结果如下:m=4.3, n=3m...
采用冒泡法对数组a中的整数由小到大进行排...