下列程序的运行结果是() #includeusing namespace ...
发布于 2022-03-03 15:12:19
下列程序的运行结果是()
#includeusing namespace stdclass base {public:int nbase(int x) { n = x}virtual void set(int m) { n = m cout << n <<' '}}class deriveA:public base{public:deriveA(int x):base(x) { }void set(int m) { n += m cout << n <<' '}}class deriveB:public base{public:deriveB(int x):base(x) { }void set(int m) { n +=m cout <<n << ' '}}void f(base p){p.set(0)}int main() { deriveA d1(1) deriveB d2(3) f(d1) f(d2) return 0 }
登录后免费查看答案
关注者
0
被浏览
13