河南成教 / C++程序设计
7[完成题]
在下面程序横线处填上适当的字句,使其输出结果为0,56,56。
7[完成题]
在下面程序横线处填上适当的字句,使其输出结果为0,56,56。
#include <iostream.h>
class base{
public:
在下面程序横线处填上适当的字句,使其输出结果为0,56,56。
#include <iostream.h>
class base{
public:
_________func( ){return 0;}
};
class derived:public base{
public:
int a,b,c;
_________ setValue(int x,int y,int z){a=x;b=y;c=z;}
int func( ){return(a b)*c;}
};
void main()
{
base b;
derived d;
cout<<b.func( )<<′,′;
d.setValue(3,5,7);
cout<<d.func( )<<′,′;
base& pb=d;
cout<<pb.func( )<<end1;
}
func( ){return 0;}
};
class derived:public base{
public:
int a,b,c;
_________ setValue(int x,int y,int z){a=x;b=y;c=z;}
int func( ){return(a b)*c;}
};
void main()
{
base b;
derived d;
cout<<b.func( )<<′,′;
d.setValue(3,5,7);
cout<<d.func( )<<′,′;
base& pb=d;
cout<<pb.func( )<<end1;
}
参考答案: