请在mian函数中填空使下面程序的输出结果为1 1。
include<iostream.h>
class A
{ private:
int a;
int b;
public:
A( ):a(0) ,b(1) { }
void show( ) { cout < < a < < " " < < b;} };
class B
{ private:
int a;
int c;
public:
B( ):a(1),
第1题:
下面程序运行时输出结果为【 】。
include<iostream.h>
include<malloc.h>
class Rect
{
public:
Rect(int1,int w)(length=1;width=w;)
void Print(){cout<<"Area:"<<length *width<<endl;)
void *operator new(size-t size){return malloc(size);}
void operator delete(void *p){free(p)
private:
int length,width;
};
void main()
{
Rect*p;
p=new Rect(5,4);
p->Print();
delete p;
}
第2题:
下面程序的输出结果为 【 】 。
include<iostream.h>
void main( )
{
int num=0,i=8;
do{
i--;
num ++;
}while(--i);
cout<<num<<end1;
}
第3题:
下面程序的结果为 #include<iostream.h> int c; class A { private: int a; static int b; public: A( ) {a=0;c=0;} void seta( ){a++;} void setb( ){b++;}
A.1 2 1
B.1 2 2
C.1 1 2
D.2 2 2
第4题:
下面这个程序的结果是
#include<iostream.h>
class A
{
private:
int a;
public:
void seta( ) ;int geta( ) ;};
void A: :seta( )
{ a=1;}
int A: :geta( )
{ retum a;}
class B
{ private:
int a;
public:
void seta( ) ;int geta( ) ;};
void B: :seta( )
{a=2;}
int B: :geta( )
{return a;}
class C: public A,public B
{ private:
int b;
public:
void display( ) ;};
void C: :display( )
{ int b=geta( ) ;
cout < < b;}
void main( )
{ C c;
c. seta( ) ;
c. display( ) ;}
A.1
B.2
C.随机输出1或2
D.程序有错
第5题:
下面这个程序的结果是 #include<iostream.h> class A { private: int a; public: void seta( );int geta( );}; void A::seta( ) { a = 1;} int A::geta( ) {return a;} class
A.1
B.2
C.随机输出1或2
D.程序有错