单项选择题

<上一题 目录 下一题>
热门 试题

单项选择题
为完成下面的程序,应在划线处填入的语句是( )。 #include <iostream> using namespace std; class Base { private: int x; public: Base(int i) { x=i; } ~Base(){} }; class Derived : public Base { public: _______________ 完成类Derive构造函数的定义 }; int main() { Derived Obj; return 0; }
A.Derived(int :Base({}
B.Derived(){}
C.voidDerived(int :Base(0){}
D.Derived(int {Base(;}
单项选择题
以下程序企图把从键盘终端输入的字符输出到名为abc.txt的文件中,当从终端读到字符’#’时,结束输入和输出操作。但该程序有错。 #include <iostream> #include <fstream> using namespace std; int main() { ofstream ofile; char ch; ofile.open( d: abc.txt , ’W’); do{ cin>>ch; ofile.put(ch); }while(ch!=’#’); ofile.close(); return 0; } 程序出错的原因是( )。
A.成员函数open调用形式错误
B.输入文件没有关闭
C.成员函数put调用形式错误
D.对象ofile定义错误
相关试题
  • 若以下定义: struct link { int dat...
  • 设有以下说明语句: typedef struct {...
  • 以下选项中,( )是合法的用户标识符。
  • 首先访问结点的左子树,然后访问该结点,最...
  • 下列对字符数组进行初始化的语句中,正确的...