单项选择题

有如下程序:
#include<iostream>
using namespace std;
class A
public:
static int a;
void init( )a=l;
A(int a=2)init( );a++;
;
int A::a=0;
A obj;
int main( )
cout<<obj.a;
return 0;
程序的输出结果是

A.0
B.1
C.2
D.3
<上一题 目录 下一题>
热门 试题

单项选择题
有如下程序: #include <iostream> using namespaee std; class Point public: static int number; Point( )number++; ~Point( )number--; ; int Point::number=0; void main( ) Point*ptr; Point A,B; Point*ptr_point=new Point[3]; ptr=ptr_point; Point C; cout<<Point::number<<endl; delete[ ]ptr; 程序的输出结果是
A.3
B.4
C.6
D.7
单项选择题
虚函数支持多态调用,一个基类的指针可以指向派生类的对象,而且通过这样的指针调用虚函数时,被调用的是指针所指的实际对象的虚函数,而非虚函数不支持多态调用。有如下程序: #include <iostream> using namespaee std; class Base public: virtual void f( )cout<< f0+ ; void g( )cout<< gO+ ; ; class Derived:public Base public: void f( )cout<< f+ ; void g( )cout<< g+ ; ; int main( ) Derived d; Base*P=&d: p->f( );p->g( ); return 0; 程序的输出结果是
A.f+g+
B.f0+g+
C.f+g0+
D.f0+g0+
相关试题
  • Date
  • 空格
  • 0
  • 下列程序的输出结果为: Ohject id=0 ...
  • friend:Date