/*
请将如下程序补充完整,使得程序运行时的输出结果为:
0, 0, 0
2, 4.6
注意:仅允许在指定的下划线处填写代码,不得改动程序中的其他内容(需删除下划线)。
试题源程序如下:
*/
#include
using namespace std;
class Base {
public:
/**********FILL**********/
Base(int a) { idata=a; }
void print() { cout<", "; } //
private:
int idata;
};
/**********FILL**********/
class Derived:public Base{
public:
/**********FILL**********/
Derived():Base(0) { ddata = 0; } //构造
Derived(int a, double b):Base(a) { ddata=b; } //重载
void print() { //
/**********FILL**********/
Base::print();
cout<private:
double ddata;
};
int main() {
Derived d1,d2(2,4.6);
d1.Base::print(); //
d1.print();
d2.print();
return 0;
}
没问题呀,你这个项目下是不是还有其他的源文件,重新建一个项目试试