填空题
下列程序的运行结果是______。
#include<iostream.h>
class Base
{
public:
void f(int x){cout<<"Base:"<<x<<endl;}
};
class Derived:public Base
{
public:
void f(char*str){cout<<"Derived:"<<str<<endl;)
};
void main(void)
{
Base*pd=new Base;
pd=new Derived;
pd->f(’a’);
}
【参考答案】
Base:97
热门
试题
填空题
下列程序的执行结果为________。#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=l;}void fun(Point&s){cout<<s.Area( )<<endl;}void main( ){Rectangle rec(3.0,5.2,15.0,25.0);fun(rec);}