有如下程序 public class Sun { public static void main(String args[ ]) { int x=0; int n=0; while(x<50) { x=(x+2)*(x+3); n=n+1; } System.out.println(n+"和"+x); } } 上述程序的运行结果是( )。
A.1和0
B.2和72
C.3和50
D.4和168
第1题:
下面程序段中的错误语句是 ______。 class M{ int i; public: void ~AA(int); AA *p; void AA(); void AA(int x){i=x;}; };
A.AA *p;
B.void ~AA(int);
C.void AA(int);
D.void AA(int x){i=x;};
第2题:
如下程序的输出结果是 #include<iostream> using namespace std; class MyClass{ public: MyClass(int i=0){cout<<1;} MyClass(const MyClass&x)}cout<<2;} }; int main( ){ MyClass objl(1),obj2(2),ohj3(objl); return 0; }
A.112
B.111
C.121
D.113
第3题:
第4题:
若有以下程序: #include <iostream> using namespace std; class Base { public: Base() { x=0; } int x; }; class Derivedl: virtual public Base { public: Derivedl() { x=10; } }; class Derived2: virtual public Base { public: Derived2() ( x=20; } }; class Derived: public Derivedl,protected Derived2 { }; int main() { Derived obj; cout<<obj.x<<end1; return 0; } 该程序运行后的输出结果是
A.20
B.30
C.10
D.0
第5题:
第6题:
如下代码中,类 X 的拷贝构造函数的数量是 class X { public: X(); X(int&); X(const X&, int = 1); ~X(); };