• 2022-06-06
    已知程序段如下: class List { public: void Copy(List L) { if (this == &L) cout << "Same!\n"; else cout << "Different!\n"; } }; int main() { List L; L.Copy(L); return 0; } 程序的输出结果是____
    A: Same!
    B: Different!
    C: 本题只有AB两个选项,无需选此项
    D: 本题只有AB两个选项,无需选此项
  • B

    举一反三

    内容

    • 0

      已知不带头结点的单链表L,下面用函数实现的在第一个元素前面插入值为x的元素结点的算法错误的是( ) A: void insert(List *L,elemtype x){ node d=new node(x); d.next=*L; *L=&d;} B: List * insert(List *L,elemtype x){ node d=new node(x); d.next=*L; *L=&d; return L;} C: void insert(List *L,elemtype x){ ptr p=*L; node d=new node(x); ptr q=&d; p->next=q; L=&q;} D: List insert(List *L,elemtype x){ node d=new node(x); d.next=*L; return &d;}

    • 1

      有如下程序: #include <iostream> using namespace std; class A public: A: A(int i)X=i; B: void dispa( )cout<<x<<','; C: private: D: int x; E: ; F: class B:public A G: public: H: B(int i):A(i+10)x=i; I: void dispb( )dispa( );cout<<x<<endl; J: private: K: int x; L: ; M: int main( ) N: B b(2); O: b.dispb( ); P: return 0; Q: 程序的输出结果是 A) 10,2 R: B) 12,10 S: C) 12,2 T: D) 2,2

    • 2

      请阅读以下程序: void main( ) { int a= 5, b= 0, c = 0; if ( a = b+c) cout << ″***\n″; else cout<< ″$$$\n″; } 以上程序_____。

    • 3

      下面程序的运行结果为 #include<iostream.h> Class A static int n; public: A( ) n=1; A: A(int num) n=num; B: void print( ) cout < < n; C: ; D: int A: :n=2; E: void main( ) F: A a,b(3) ; G: a. print( ) ; H: b. print( ) ; I: cout < < endl;A) 11 J: B) 13 K: C) 23 L: D) 33

    • 4

      下列程序运行结果是 。class A{public:virtual void funcl(){cout&#91;< "A1";}void func2(){cout<< "A2";}};class B: public A{public:void func1(){cout<< "B1";}void func2(){cout<< "B2";}};int main(){A *p=new B;p-&#93;funcl();p->func2();return 0;}