下列程序的运行结果是【 】。
include <iostream. h>
class SomeClass
{
public:
SomeClass(int value) { some_value=value;};
void show_data(void) { cout<<data<<"<<~some_value<<endl; };
static void set_data(int value) {data=value; }
private:
static int data;
int some_value
};
int SomeClass::data
void main(void)
{
SomeClass my_class(1001),your_class(2002);
your_class. set_data(4004);
my_elass. show_data()
}
第1题:
以下程序的运行结果是______。
include<iostream.h>
include<math.h>
template<class T>
class TAdd//定义类模板TAdd,T为类型
{
Tx,y;
public:
TAdd (Ta,Tb) {x=a,y=b;) //构造函数
Tadd() { retum x+y;}//成员函数
};
void main( )
{
TAdd<int>A (5,6);
第2题:
下列程序的运行结果是
#include<iostream.h>
class A
{
int a;
public:
A( ) {a=0;}
A(int aa)
{
a=aa;
cout < < a++;
}
};
void main( )
A x,y(2) ,z(3) ;
cout < < endl;
}
A.00
B.23
C.34
D.25
第3题:
下列程序的运行结果是______。
include<iostream.h>
class Base
{
public:
virtual void func(int i){cout<<"class Base:"<<i<<end1;)
};
class Derived: public Base
{
public:
void func(double d){cout<<"class Derived:"<<d<<endl;}
};
void main( )
{
Base a,*p=a;
Derived b;
p=&b;
(*p).func(3.3);
}
第4题:
下列程序的运行结果是【 】。
include<iostream, h>
class Sample
{
int a;
public:
Sample(int aa=0) {a=aa;}
~Sample() {cout<<"Sample="<<a<<;}
class Derived: public Sample
{
int b;
public:
Derived(int aa=0, int bb=0): Sample(aa) {b=bb;}
~De rived() {cout <<"Derived="<<b<<'';}
void main()
{
Derived dl (9)
}
第5题:
下列程序的运行结果是( )。 #include<iostream.h> class A { inta; public: A(){a=0:} A(int aa) { a=aa; cout<<a++; } }; void main() { A x,y(2),z(3); cout<<endl; }
A.0
B.23
C.34
D.25