• 2022-06-01 问题

    下列程序运行结果是 。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;}

    下列程序运行结果是 。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;}

  • 2022-06-01 问题

    ‏有如下程序:​#include&#91;iostream.h&#93; class A { public: virtual void func1( ){cout&#91;<"A1";} void func2( ){cout<<"A2";} }; class B:public A { public: void func1( ){cout<<"B1";} void func2( ){cout<<"B2";} }; void main( ) { A *p=new B; p-&#93;func1( ); p->func2( ); }‏执行该程序,屏幕上将显示输出( )。​ A: B1B2 B: A1A2 C: B1A2 D: A1B2

    ‏有如下程序:​#include&#91;iostream.h&#93; class A { public: virtual void func1( ){cout&#91;<"A1";} void func2( ){cout<<"A2";} }; class B:public A { public: void func1( ){cout<<"B1";} void func2( ){cout<<"B2";} }; void main( ) { A *p=new B; p-&#93;func1( ); p->func2( ); }‏执行该程序,屏幕上将显示输出( )。​ A: B1B2 B: A1A2 C: B1A2 D: A1B2

  • 2022-06-17 问题

    下列程序的执行结果是___________。 #include&#91;iostream.h&#93; class A { public: A() { cout&#91;<endl<<"实例化类A的一个对象。"; } virtual ~A() { cout<<endl<<"消除类A的一个对象。"; } virtual void f() { cout<<endl<<"执行类A的成员函数。"; } }; class B:public A { public: B() { cout<<endl<<"事例化类B的一个对象。"; } virtual ~B() { cout<<endl<<"消除类B的一个对象。"; } void f() { cout<<endl<<"执行类B的成员函数。"; } }; void main() { A a=A(); B b=B(); cout<<endl<<"----------"; a.f(); b.f(); cout<<endl<<"----------"; A *p; p=&b; p-&#93;f(); cout<<endl<<"----------"; }

    下列程序的执行结果是___________。 #include&#91;iostream.h&#93; class A { public: A() { cout&#91;<endl<<"实例化类A的一个对象。"; } virtual ~A() { cout<<endl<<"消除类A的一个对象。"; } virtual void f() { cout<<endl<<"执行类A的成员函数。"; } }; class B:public A { public: B() { cout<<endl<<"事例化类B的一个对象。"; } virtual ~B() { cout<<endl<<"消除类B的一个对象。"; } void f() { cout<<endl<<"执行类B的成员函数。"; } }; void main() { A a=A(); B b=B(); cout<<endl<<"----------"; a.f(); b.f(); cout<<endl<<"----------"; A *p; p=&b; p-&#93;f(); cout<<endl<<"----------"; }

  • 2022-06-17 问题

    阅读下列程序,写出运行结果。 #include &#91;iostream&#93; using namespace std; int main() { int a = 1, b = 2; bool x, y; cout &#91;< (a++)+(++b) << endl; cout << a % b << endl; x = !a&#93;b; y = a-- && b; cout << x << endl; cout << y << endl; }

    阅读下列程序,写出运行结果。 #include &#91;iostream&#93; using namespace std; int main() { int a = 1, b = 2; bool x, y; cout &#91;< (a++)+(++b) << endl; cout << a % b << endl; x = !a&#93;b; y = a-- && b; cout << x << endl; cout << y << endl; }

  • 2022-06-17 问题

    下列程序的输出结果第一行是_____,第二行是_______。 #include &#91;iostream&#93; #include &#91;cstring&#93; #include &#91;iomanip&#93; using namespace std; struct student { int num; char name&#91;20&#93;; double score; }; void fun(struct student *s); int main() { struct student stu={12345, "Zhangwei", 98.0}; cout&#91;<stu.num<<","<<stu.name<<","<<stu.score<<endl; fun(&stu); cout<<stu.num<<","<<stu.name<<","<<stu.score<<endl; return 0; } void fun(struct student *s) { s-&#93;num=23456; strcpy(s->name, "Liming"); s->score=88; }

    下列程序的输出结果第一行是_____,第二行是_______。 #include &#91;iostream&#93; #include &#91;cstring&#93; #include &#91;iomanip&#93; using namespace std; struct student { int num; char name&#91;20&#93;; double score; }; void fun(struct student *s); int main() { struct student stu={12345, "Zhangwei", 98.0}; cout&#91;<stu.num<<","<<stu.name<<","<<stu.score<<endl; fun(&stu); cout<<stu.num<<","<<stu.name<<","<<stu.score<<endl; return 0; } void fun(struct student *s) { s-&#93;num=23456; strcpy(s->name, "Liming"); s->score=88; }

  • 2022-06-11 问题

    在下面的程序代码段中,如果要得到输出结果:pi= 3.14,则在横线处,应该补充的语句是 。[br][/br] #include &#91;iostream.h&#93; #include &#91;iomanip.h&#93; void main( ) { double pi= 3.1415926; cout<<setiosflags(ios::fixed); ; cout<<" pi= "<<pi<<endl; }

    在下面的程序代码段中,如果要得到输出结果:pi= 3.14,则在横线处,应该补充的语句是 。[br][/br] #include &#91;iostream.h&#93; #include &#91;iomanip.h&#93; void main( ) { double pi= 3.1415926; cout<<setiosflags(ios::fixed); ; cout<<" pi= "<<pi<<endl; }

  • 2022-06-16 问题

    下列程序执行后的输出结果是______。 #include &#91;iostream&#93; using namespace std; class A { public: A( ) { cout << "A"; } }; class B { public: B( ) { cout << "B"; } }; class C : public A { private: B b; public: C( ) { cout << "C"; } }; void main ( ) { C obj; } A: CBA B: BAC C: ACB D: ABC

    下列程序执行后的输出结果是______。 #include &#91;iostream&#93; using namespace std; class A { public: A( ) { cout << "A"; } }; class B { public: B( ) { cout << "B"; } }; class C : public A { private: B b; public: C( ) { cout << "C"; } }; void main ( ) { C obj; } A: CBA B: BAC C: ACB D: ABC

  • 2022-06-17 问题

    填空使下列程序正常运行#include &#91;iostream&#93; int main(){ int qq=3; cout<<qq<<endl;}

    填空使下列程序正常运行#include &#91;iostream&#93; int main(){ int qq=3; cout<<qq<<endl;}

  • 2022-05-29 问题

    以下if语句语法正确的是( )。 A: if(x>0) cout<<xelse cout<<--x; B: if(x>0){ x=x+y; cout<<x; }else cout<<--x; C: if(x>0){ x=x+y; cout<<x; };else cout<<--x; D: if(x>0){ x=x+y; cout<<x };else cout<<--x;

    以下if语句语法正确的是( )。 A: if(x>0) cout<<xelse cout<<--x; B: if(x>0){ x=x+y; cout<<x; }else cout<<--x; C: if(x>0){ x=x+y; cout<<x; };else cout<<--x; D: if(x>0){ x=x+y; cout<<x };else cout<<--x;

  • 2022-05-29 问题

    下列程序的运行结果是 。class Stack{ char * sp ;public : Stack( ){ sp = new char&#91;100&#93; ; strcpy(sp , "I love China") ; cout << "在构造函数中! \n" ; } ~Stack( ){ cout << sp << endl ; delete &#91; &#93;sp ; cout << "在析构函数中! \n" ; }} ;void main( ){ Stack s ; }

    下列程序的运行结果是 。class Stack{ char * sp ;public : Stack( ){ sp = new char&#91;100&#93; ; strcpy(sp , "I love China") ; cout << "在构造函数中! \n" ; } ~Stack( ){ cout << sp << endl ; delete &#91; &#93;sp ; cout << "在析构函数中! \n" ; }} ;void main( ){ Stack s ; }

  • 1 2 3 4 5 6 7 8 9 10