题目内容

分析下列程序,写出程序运行结果____。#includeusing namespace std;class A{public:virtual void f( ){cout<<1; }void g( ){ cout<<2; }};class B: public A {public:virtual void f( ){ cout<<3; }void g( ){ cout<<4; }};void show( A &a) { a.f( ); a.g( ); }void print(A *p){ p->f(); p->g();}int main(void){B b;show(b);print(&b);cout<

查看答案
更多问题

分析下列程序,写出程序运行结果。#includeusing namespace std;class A{protected:static int num;public:A( ){ num++; cout<

分析下列程序,写出程序运行结果。#includeusing namespace std;class A{protected:static int num;public:A( ){ num++; cout<

分析下列程序,写出程序运行结果。#includeusing namespace std;class A{public:A(char *s){ cout<

根据下列程序的运行结果,在空格处填上适当的语句,使其能正确执行。#includeusing namespace std;class Base1{protected:char str[20];public:Base1(char *s) { strcpy(str,s); }};class Base2{char str[20];public:Base2(char *s) { strcpy(str,s); }char* get(){ return str; }};class Derived: Base1{char str[20];Base2 obj;public:Derived(char *s1, char *s2, char *s3): Base1(s1),____{strcpy(str,s3);}void print() { cout<<____<<'\n'<<____<<'\n'<

答案查题题库