以下程序的输出结果是_____。
include<iostream.h>
class object
{ private:
int val;
public:
object( ) ;
object(int i) ;
~object( ) ;};
object: :object( )
{ val=0;
cout < < "Default constructor for object" < < endl;}
object: :object(int i)
{ val=i;
cout < < "Constructor for object" < < val < < endl;}
object: :~object( )
{ cout < < "Destructor for object" < < val < < endl;}
class container{ private:
object one;
object two;
int data;
public:
container( ) ;
container(int i,int j,int k) ;
~container( ) ;};
container: :container( )
{ data=0;
cout < < "Default constructor for container" < < endl;}
container: :container(int i,int j,int k) :two(i) ,one(j)
{ data=k;
cout < < "Constructor for container" < < endl;}
container: :~container( )
{ cout < < "Destructor for container" < < endl;}
void main( )
{ container anObj(5,6,10) ;}
第1题:
下列程序的运行结果是 #include<iostream.h> class Location{ private: int X.Y; public: void init(int=0,int=0); void valueX(int val){X=val;} int valueX( ){ return X;} void valueY
A.5 0 6 4
B.0 0 6 4
C.5 0 6 2
D.0 0 6 2
第2题:
下面这个程序的结果是 #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.程序有错
第3题:
以下程序的执行结果是______。
include<iostream.h>
class CSample
{
private:
int n;
static int k:
public:
CSample (int i) {n=i;k++;};
voiddisp();
} ;
void CSample::disp()
{
cout <<"n="<<n<<",k="<<k<<endl
}
int CSample:
第4题:
有如下程序: #include<iostream> using namespace std; class Part{ public: Part(int x=0):val(x) {cout<<val;} ~Part(){cout<<val;} private: int val; }; class Whole{ public: Whole(int x ,int y, int z=0):p2(x),p1(y),val(z){cout<<val;} ~Whole(){cout<<val;} private: Part p1,p2; int val; }; int main() Whole obj(1,2,3); return 0; } 程序的输出结果是( )。
A.123321
B.213312
C.213
D.123123
第5题:
以下程序的执行结果是 ( )。 #include <iostream> using namespace std; class sample { private: int x; public: sample (int A) { x=a; } friend double square(sample s); }; double square(sample s) {
A.20
B.30
C.900
D.400