单项选择题

以下程序的执行结果为( )。 #include<iostream.h> Class sample { int n; public: sample(int i){n=i; } operator ++() { n++; } void display() {cout<<n<<end1; } }; void main() { sample obj(5); obj++; obj.display(); }

A.5
B.6
C.7
D.8
<上一题 目录 下一题>
热门 试题

单项选择题
有以下程序: #include <iostream> using namespace std; int main() { int x; for(int i=1;i<=100;i++) { x=i; if (++x%2==0) if (++x%3==0) if (++x%7==0) cout<<x<< , ; } cout<<end1; return 0; } 执行后输出结果是( )。
A.39,81
B.42,84
C.26,68
D.28,70
单项选择题
有以下程序: #include <iostream> #include <string> using namespace std; class base { private: char baseName[10]; public: base ( ) { strcpy (baseName, Base ); } virtual char *myName() { return baseName; } char *className() { return baseName; } }; class Derived : public base { private: char derivedName[10]; public: Derived() { strcpy(derivedName, Derived ); } char *myName() { return derivedName; } char *className() { return derivedName; } }; void showPtr(base &p) { cout<<p.myName()<< <<p.className() ; } int main () { base bb; Derived dd; showPtr(dd) ; return 0; }
A.DerivedBase
B.BaseBase
C.DerivedDerived
D.BaseDerived
相关试题
  • 有以下程序:#include <iostream>using...
  • 有如下的类的模板定义:template <class...
  • 有以下程序:#include <iostream>using...
  • 设文件temp.txt 已存在,则以下的打印结...
  • 将下面的语句段(A) 补充完整,使其和语...