题目内容

要实现动态连编,派生类中的虚函数()。

A. 返回的类型可以与虚函数的原型不同
B. 参数个数可以与虚函数的原型不同
C. 参数类型可以与虚函数的原型不同
D. 以上都不对

查看答案
更多问题

有如下程序:#includeusing namespace std;class shapes{protected:int x,y;public:void setvalue(int d,int w=0){x=d;y=w;}virtual void disp()=0;};class square:public shapes{public:void disp(){cout<setvalue(10,5);ptr->disp();return 0;}

A. 50
B. 5
C. 10
D. 15

下面的程序段中虚函数被重新定义的方法正确吗?class base{public:virtual int f(int a)=0;......};class derived: public base{public:int f(int a,int b){return a*b;}......};

A. 对
B. 错

(1)写出程序的运行结果。#includeusing namespace std;class Stock{public:void print(){cout<<"Stock class.\n";}};class Der1_Stock:public Stock{public:void print(){cout<<"Der1_Stock class.\n";}};class Der2_Stock:public Stock{public:void print(){cout<<"Der2_Stock class.\n";}};int main(){Stock *ptr,s1;Der1_Stock d1;Der2_Stock d2;ptr=&s1;ptr->print();ptr=&d1;ptr->print();ptr=&d2;ptr->print();return 0;}(2)修改上一题的程序,使运行结果为:Stock class.Der1_Stock class.Der2_Stock class.

1. The auther went quickly into the shop to ___________ .

A. buy a pair of shoes
B. meet one of his old friends
C. have his shoes repaired
D. learn to build a tradition

答案查题题库