一起答
单选

C++语言是以()语言为基础逐渐发展演变而成的一种程序设计语言。

  • A.Pascal
  • B.C
  • C.B
  • D.Simula 67
参考答案
查看试卷详情
相关试题
  1. 有两个矩阵a和b,都是2行3列。求两个矩阵之和。重载运算符“+”,使之能用于矩阵相加。如=a+b。

  2. 给出下面程序输出结果。

    #include

    void main()

    {int*p1;

    Int**p2=&p1;

    int b=20;

    p1=&b;

    cout<<**p2<

    }

  3. 给出下面程序的输出结果。

    #include< iostream.h>

    template

    class Complex

    {T real,image;

    public

    Complex(T a, T b): real(a){ image=b;}

    Complex(T a){image=0,real=a;}

    void pr()

    {char c;

    c=(image>0'+':'-');

    if (image!=0)

    cout<0? image:-image)<<"i"<

    else

    Cout<

    }

    };

    void main()

    {Complexa(16.5,-7.8);

    a.pr()

    Complexb(6);

    b.pr();

    }

  4. 在下面横线处填上正确的内容,完成类的定义。

    class Base

    }

    int x;

    static const int b:

    public:

    Base(int,int);

    const int &a;

    };

    ___________b=15;

    Base::Base(int i, int j):___________{}

  5. 计算1~20之间偶数之和。

    #include

    void main()

    {int a,i;

    a=0;

    for(i=0;i<21;_________)

    {

    _________

    }

    cout<<"偶数之和为:"<

    }

  6. 下面程序用来求直角三角形斜边长度。

    #include

    #include

    class Point

    {private:

    double x,y;

    __________

    public:

    Point(double i=0,double j=0)

    {x=i,y=j}

    Point(Point &p)

    {x=p.x; y=p.y;}

    };

    class Line

    {private:

    Point p1,p2;

    public:

    Line(Point &xp1, Point &xp2):__________{}

    double GetLength();

    };

    double Line: GetLength()

    {double dx=p2.x-p1.x;

    double dy=p2.y-p1.y;

    return sqrt(dx*dx+dy*dy)

    }

    void main()

    {Point p1, p2(6,8);

    Line L1(p1,p2);

    cout<

    }

  7. #include

    class AA

    {public:

    AA()

    {A=i;B=j;cout<<"Constructor\n";}

    AA(AA &obj)

    {A=obj.A;

    B=obj.B;

    cout<<"Copy Constructor\n";

    }

    ~AA(){cout<<"Destructor\n";}

    void show()

    {cout<<"A="<

    private:

    int A,B:

    };

    void main()

    {AA a1(2,3);

    AA a2(a1);

    a2.show();

    _________= &a2;

    pa->show();

    }

  8. 下面程序实现数值、字符串的交换。

    #include

    #include

    using namespace std;

    template

    void Swap(T&a,T&b)

    {T temp;

    temp=a;a=b;b=temp;

    }

    void main()

    {int a=5,=9;

    char s1[]="Hello",s2[]="hi";

    Swap(a,b);

    Swap(s1,s2);

    cout<<"a="<

    cout<<"s1="<

    }

  9. 完成下面类中成员函数的定义。

    #include

    #include

    using namespace std;

    class str

    {private:

    char*st;

    public:

    str(char *a)

    {set(a);}

    str& perator=(_______)

    {delete st;

    set(a.st);

    return*this;}

    void show(){cout<

    ~str(){delete st;}

    void set(char*)//初始化st

    {________

    strcpy(st,s);

    }

    };

    void main()

    {str s1("he"), s2("she");

    S1.show(), s2.show()

    s2=s1;

    s1.show() ,s2.show();

    }

  10. #include 

    using namespace std;

    void main(){

    int x=32,y=37;

    const int*p=&x;

    *p=y;

    cout<<*p<

    }