整专业资料
微信QQ群
考生网QQ群

群号:517231281

扫码加群
点击二维码加群

考生网微信公众号

微信号:zikaosw

课程试听
最新资讯

手机端访问

1、直接输入www.zikaosw.cn
2、扫描左侧二维码

登录 | 注册
登录/注册后,可享受
  • 课程免费试听
  • 试做在线题库
  • 学习提升指导
  • [主观题] 【程序分析题】阅读程序,写出运行结果。
    #include
    using namespace std;
    class A
    {public:
    A( ){a=0;b=0;}
    A(int i){a=i;b=0;}
    A(int i,int j){a=i;b=j;}
    void display( ){cout<<"a="<<a<<" b="<<b;}
    private:
    int a;
    int b;
    };

    class B : public A
    {public:
    B( ){c=0;}
    B(int i):A(i){c=0;}
    B(int i,int j):A(i,j){c=0;}
    B(int i,int j,int k):A(i,j){c=k;}
    void display1( )
    {
    display();
    cout<<" c="<<c<<endl;
    }
    private:
    int c;
    };

    int main( )
    { B b1;
    B b2(1);
    B b3(1,3);
    B b4(1,3,5);
    b1.display1( );
    b2.display1( );
    b3.display1( );
    b4.display1( );
    return 0;
    }

     纠错    

  • 助考班推荐

您可能感兴趣的试题

  • 1、[单选题]设有函数:T max(T x,T y){return x==y?x:y;},其中T为模板类型,下列相
    关分析正确的是( )

    • A、该函数模板有两个模板类型参数
    • B、T所规定的类型不可以是自定义类型
    • C、生成模板函数中的x和y的类型必须相同
    • D、生成模板函数的参数和返回值的类型可以不同
  • 2、[填空题]将部分成员函数声明为______,用于提供外界和这个类对象相互作用的接口,从而使得其它函数也可以访问处理该类的对象。

  • 3、[主观题]【程序分析题】#include
    using namespace std;class data
    {
    int x;public:
    data(int X){data::x=x;cout<<"class data"<class School
    data dl;public:
    School(int x):d1(x){cout<<"School"<class Course:public School{
    data d2;public:
    Course(int x):School(x),d2(x){cout<<"Course"<class Score:public Course
    public:
    Score(int x):Course(x){cout<<"Score"<int mainO
    Score obj(1);
    【原题如下】

  • 4、[主观题]【程序分析题】#include
    using namespace std;class Math
    protected:
    int k;public:
    Math(int n=5):k(n){cout<virtual void f)const=O;};
    inline void Math::f(const{cout<public:
    ~AddO{cout<<"Add";}void f0 const
    {
    cout<};
    int main)
    Math&p=*new Add;p.fO;
    delete&p;return 0;
    【原题如下】

  • 5、[主观题]【程序分析题】#include
    #includeusing namespace std;int main)
    double x=10.456;
    cout<cout<<"10(十六)="<cout.setf(ios:-scientific);cout<return 0;
    【原题如下】

Copyright © 2010 - 2023 湖南求实创新教育科技有限公司 All Right Reserved.

温馨提示:如您需要的资料本网暂时没有,请于工作日08:00-18:00,点击这里,联系客服及时补充资料。