阅读下列说明和C++代码,回答问题。 [说明] 已知下列程序运行时的输出应为: 1:1 1:1 1:1 [C++程序] 01 #include <iostream> 02 using namespace

admin2012-04-11  20

问题 阅读下列说明和C++代码,回答问题。
   [说明]
   已知下列程序运行时的输出应为:
   1:1
   1:1
   1:1
   [C++程序]
   01  #include <iostream>
   02  using  namespace  std;
   03  class  stick{
   04  protect;
   05   _________ {};
   06  Stock(int n, int pr=1) {
   07  shares=n;  share_val=pr;
   08  };
   09  void~stock(    ) {};
   10  public:
   11  //成员函数
   12  void output(    ){
   13   ________ <<shares<<":"<<share val<<endl;
   14  }
   15  private:
   16  //成员变量
   17  int  shares;
   18  int  share_val;
   19  };
   20
   21  void main(    ){
   22  Stock a(1); a. output(    );
   23  Stock b; b. output(    );
   24  Stock C=Stock(    ); c.output(    );
   25  }
请补齐上述代码中的空缺(1)和(2)。

_____
_____

选项

答案Stock( ):shares(1),share_val(1)或Stock( ):share_val(1),shares(1)。 Cout

解析
转载请注明原文地址:https://kaotiyun.com/show/GbVZ777K
0

最新回复(0)