一起答
单选

C++的合法注释是()

  • A./*This is a C program/*
  • B.//This is a C program
  • C."This is a C program"
  • D.//This is a C program//
参考答案
查看试卷详情
相关试题
  1. 已定义一个Shape抽象类,在此基础上派生出矩形Rectangle和圆形Circle类,二者都有GetPerim()函数计算对象的周长,并编写测试main()函数。

    #include

    using namespace std;

    class Shape

    {public:

    Shape(){ }

    ~Shape(){ }

    virtual float GetPerim()=0;

    };

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

    #include

    #include

    #include

    bool fun(long n);

    void main()

    {long a=10,b=30,1=0;

    if(a%2=0)a++;

    for(long m=a;m<=b;m+=2)

    if(fun(m))

    {if(1++%10=0)

    cout<

    cout<

      }

    }

    bool fun(long n)

    {int sqrtm=(int)sqrt(n);

    for(int=2;i<=sqrtm; i++)

    if(n%i==0)

    retur false;

    return true;

    }

  3. 运行程序,写出程序执行的结果。

    #include

    void main()

    {int a,b;

    char ch;

    cin>>a>>ch>>b;//从键盘上输入1.5 c 10

    }

  4. 在下面程序横线处填上适当内容,使程序执行结果为:200_ _100

    #include

    template

    T f(____________)

    {if(____________)

    return x+y;

    else

    return x*y;

    }

    void main()

    {cout<

  5. 在下面程序横线处填上适当内容,使程序执行结果为:Y=1,Y=3,Z=5

    #include

    class B

    {private:

    int Y

    public:

    B(inty=0){Y=y;}

    void print(){cout<"Y="<

    };

    class D:public B

    {private:

    B b;

    int Z;

    public:

    D(int x,int y,int z):B(x),b(y){Z=z;}

    void print()

    {________;//打印基类B中的成员Y

    ________;//打印类成员b中的Y值

    cout<<"Z="<

    }

    };

    void main()

    {D d(1,3,5);

    D.print();

    }

  6. #include

    class A

    {private:

    int X,Y;

    public:

    A(){X=Y=0;}

    A(int xx,int yy):X(xx),Y(yy){}

    A(A&a){________;}

    int GetX(){return X;}

    int GetY(){return Y;}

    void SetXY(int x,int y){X=x,Y=y;}

    };

    void main()

    {A*Ptr=newA[2];

    Ptr[0].SetXY(5,10);

    Ptr[1].SetXY(15,20);

    cout<<"Release Ptr......"<

    ________;//释放动态分配内存

    }

  7. 完成下面类中构造函数的定义。

    #include

    class A

    {private:

    int y;

    int x;

    public:

    A(int,int);

    A(const A&);

    void show()

    {cout<<"x="<

    }

    };

    A::A(int i;int j):_________    

    {}

    A::A (_________)

    {x=t.x;y=t.y}

    void main()

    {A a1(3,5);

    a1.show();

    A a2(a1);

    a2.show();

    }

  8. #include

    int fun1(int);

    void main()

    {int i=12;

    ____________

    ____________

    cout<<"fun1:"<<(*fp)(i)<

    }

    int funl(int k)

    {k=k*2+1;

    return k;

    }

  9. #include

    class Aton

    {int X,Y;

    protected:

    int zx,zy;

    public:

    void init(int i,int j){zx=i;zy=j;

    Aton(int i,int j,int=0,int m=0)

    (X=i, Y =j,zx=m, zy=n;}

    };

    void main()

    Aton(25,20,3,5);

    A.init(5,9);

    cout<

  10. #include

    class X

    {public:

    int x;

    public:

    X(int x)

    {cout<x=x<

    X(X& t)

    {x=t.x;

    {cout<

    void fun(X);

    };

    void fun(X t)

    void main()

    {fun(X(10));}