题目详情
当前位置:首页 > 职业培训考试
题目详情:
发布时间:2024-01-04 20:08:12

[单项选择]有如下程序:   #include   usingnamespacestd;   intmain()   {   int*P;   *P=9:   cout<<"ThevalueatP:"<<*P;   return0;   }   编译运行程序将出现的情况是(  )。
A. 编译时出现语法错误,不能生成可执行文件
B. 运行时一定输出ThevalueatP:9
C. 运行时一定输出ThevalueatP:*9
D. 运行时有可能出错

更多"有如下程序:   #include   usingna"的相关试题:

[单项选择]有以下程序:   #include   usingnamespacestd;   classsample   {   private:   intX;   public:   sample(inta)   {   X=a:   }   frienddoublesquare(samples);   };   doublesquare(samples)   {   returnS.x*S.X:   }   intmain()   {   samples1(20),s2(30);   cout<  return0;   }   执行结果是(  )。
A. 20
B. 30
C. 900
D. 400
[单项选择]若有以下程序:   #include   usingnamespacestd;   classBase   {public:   Base()   {x=0;}   intx;};   classDerivedl:virtualpublicBase   {public:   Derivedl()   {x=10;}};   classDerived2:virtua11publicBase   {public:   Derived2()   {x=20;}};   classDerived:publicDerivedl,protectedDerived2{};intmain()   {Derivedobj;   cout<  return0;}   该程序运行后的输出结果是(  )。
A. 20
B. 30
C. 10
D. 0
[单项选择]有如下程序:   #inelude   usingnamespacestd;   classTest   {   public:   Test(){n+=2;}   ~Test(){n-=3;}   staticintgetNum(){returnn;}   private:   staticintn;   };   intTest::n=1;   intmain()   Test*P=newTest:   deleteP;   cout<<"n="<  return0;   }   执行后的输出结果是(  )。
A. n=0
B. n=1
C. n=2
D. n=3
[单项选择]有如下程序:   #included   usingnamespacestd;   classTestClass{   protected:   TestClass(  ){cout<<’X’;}   TestClass(charc){cout<  classTestClassl:publicTestClass{   public:   TestClassl(charc){cout<  intmain(  ){   TestClassld1(’y’);   return0;}   执行这个程序,屏幕上将显示输出(  )。
A. y
B. yx
C. xy
D. yy
[单项选择]若有以下程序: #include<iostream> usingnamespacestd; voidsub(intx,inty,int*2) { *z=y+x; } int main( ) { int a,b,C; sub(8,4,&A) ; sub(6,a,&B) ; sub(a,b,&C) ; cout<<a<<","<<b<<","<<c<<end1; return 0; } 程序运行后的输出结果是
A. 12,18,30
B. -12,6,8
C. 6,8,10
D. 12,-18,16
[单项选择]若有以下程序: #include<iostream> usingnamespacestd; classA { private: int x; public: int x; void setx(int i) { x=i; } int getx( ) { return x; } }; class B:public A { private: int m; public: int p; void setvalue (int a,int b,int C) { setx(A) ; z=b; m=c; } void display( ) { cout<<getx( )<<","<<z<<","<<m<<end1; } }; int main( ) { B obj; obj.setvalue(2,3,4); obj.display( ); return 0; } 程序运行以后的输出结果是
A. 产生语法错误
B. 2,3,4
C. 2,2,2
D. 4,3,2
[单项选择]有如下程序 #include #include using namespace std; class MyClass{ public: MyClass( ){cout<<′A′;} MyClass(char c){cout<<′c′;} MyClass( ){cout<<′B′;} } int main( ){ MyClass pl,*p2; p2=new MyClass(′X′); delete p2; retum 0; } 执行这个程序屏幕上将显示输出【 】
A. ABX
B. ABXB
C. AXB
[单项选择]有如下程序 #include #include using namespace std; int main( ) cout<A. setprecision(3)
B. fixed
C. setfill(′*′)
D. setw(8)
[简答题]有如下程序 #include #include using namespace std; class MyClass{ public: MyClass( ){cout<<’A”;} MyClass(char c {cout<A. A.ABX
B.ABXB
C.AXB
D.AXBB

[单项选择]有如下程序: #include #include using namespace std; class MyString{ public; char str[80]; MyString(const char*s) {strcpy(str,s);} MyString&operator+=(MyString a){ strcat(str,a.str); return*this; } }; ostream&operator<<(ostream&s,const MyString&z){return s << z.str} int main( ){ MyString x("abc"),y("cde"); cout<<(x+=y)<A. abc
B. cde
C. abcde
D. abccde
[单项选择]有如下程序: #include using namespace std; class Boat; class Car{ public: Car(int i):weight(i){ } friend int Total(const Car &c.const Boat &b); //① private: int weight; }; class Boat{ public: Boat(int i):weight(i){ } friend int Total(const Car &c,const Boat &b); private: int weight; }; int Total(const Car &c,const Boat &b){ //② return c.weight+b.weight; } int main( ){ Car c(10); Boat b(8); cout<<"The total weight is"<A. 程序编译正确
B. 程序编译时语句①出错
C. 程序编译时语句②出错
D. 程序编译时语句③出错
[单项选择]有如下程序 #include <iostream> #include <iomanip> using namespace std; class MyClass { public: MyClass( ) { cout<<’A’; } MyClass(char c){ cout<<c; } ~MyClass( ){ cout<<’B’; } }; int main( ) { MyClass p1,*p2; p2=new MyClass(’X’); delete p2; return 0; } 执行这个程序屏幕上将显示输出
A. ABX
B. ABXB
C. AXB
D. AXBB
[单项选择]

有如下程序:
  #include
  #include
  using std::cout;
  class Point{
  public:
  friend double distance(const Point &p); //p距原点的距离
  Point(int xx=0,int yy=0):x (xx),Y(YY){}//①
  private:
  Int x,Y;
  };
  double distance(const Point &p) { //②
  return sqrt(p.x*p.x+p.Y*p.Y);
  }
  int main(){
  Point p1(3,4);
  cout<  return 0;
  }
  下列叙述中正确的是()


A. 程序编译正确
B. 程序编译时语句①出错
C. 程序编译时语句②出错
D. 程序编译时语句③出错

我来回答:

购买搜题卡查看答案
[会员特权] 开通VIP, 查看 全部题目答案
[会员特权] 享免全部广告特权
推荐91天
¥36.8
¥80元
31天
¥20.8
¥40元
365天
¥88.8
¥188元
请选择支付方式
  • 微信支付
  • 支付宝支付
点击支付即表示同意并接受了《购买须知》
立即支付 系统将自动为您注册账号
请使用微信扫码支付

订单号:

截图扫码使用小程序[完全免费查看答案]
请不要关闭本页面,支付完成后请点击【支付完成】按钮
恭喜您,购买搜题卡成功
重要提示:请拍照或截图保存账号密码!
我要搜题网官网:https://www.woyaosouti.com
我已记住账号密码