填空题
下列程序的运行结果是 【11】 。
#include<iostream, h>
class Base
public:
void f(int x) cout<<"Base:"<<x<<end1;
;
class Derived: public Base
public:
void f(char * str) cout<<"Derived:"<<str<<end1;
;
void main(void)
Base * pd=new Base;
pd=new Derived;
pd->f(’a’)
【参考答案】
Base:97
热门
试题
填空题
下列程序的执行结果为 【13】 。 #include <iostream. h> class Point public: Point(double i, double j) x=i; y=j; double Area() const return 0.0; private: double x, y; ; class Rectangle: public Point public: Rectangle(double i, double j, double k, double 1) double Area() const return w * h; private: double w, h; ; Rectangle: :Rectangle(double i, double j, double k. double 1): Point(i,j). w=k, h=1 void fun(Point &s) cout<<s. Area()<<end1; void main( ) Rectangle rec(3.0, 5.2, 15.0. 25.0); fun(rec)