#include ﹤iostream.h﹥
class test1{
private: int x;
public: test1( ){x=2;}
void set(int a){x=a;}
void get(){cout﹤﹤x﹤﹤endl;}
};
class test2{
private: int x;
public: test2( ){x=3;}
void set(int a){x=a;}
void get( ){cout﹤﹤x﹤﹤endl;}
};
class test: public test1, public test2. {
private: int x;
public: void set(int a){x=a;}
void gettest( ){cout﹤﹤x﹤﹤endl;}
};
main( ) {
test a; a.get( );
}
在三角形类tri实现两个函数,功能是输入三个顶点坐标判断是否构成等边三角形 #include ﹤iostream.h﹥
#include ﹤math.h﹥
class point { point
private: float x, y;
public: f(float a, float b){x=a; y=b;}
f( ){x=0; y=0;}
Void set(float a, float b){x=a; y=b;}
float getx( ){return x;}
noat gety( ){return y;}
};
class tri{
point x, y, z;
float s1, s2, s3;
public....settri(....); //用于输入三个顶点坐标
....test(....); //用于判断是否构成等边三角形 };
请写出两个函数的过程(如果需要形式参数,请给出形参类型和数量,以及返回值类型)
#include ﹤iostream.h﹥
class A
{
public:
A( );
void Show( );
~A( );
private:
static int c;
};
int A:: c=O;
A:: A( )
{
cout﹤﹤"constructor."﹤﹤endl;
c +=10;
}
void A:: Show( )
{
cout﹤﹤"c="﹤﹤c﹤﹤endl;
}
A:: ~A( )
{
cout﹤﹤"destrucator."﹤﹤endl;
}
void main( )
{
A a, b;
a.Show( );
b.Show( );
}
#lnclude ﹤iostream.h﹥
void func( );
void main( )
{
for(int i=0; i﹤6; i++)
{
func( );
}
}
void func( )
{
int x=0;
x++;
static int y=0;
y++;
cout﹤﹤"x="﹤﹤x﹤﹤";y="﹤﹤y﹤﹤endl;
}
求两个浮点数之差的cha函数的原型声明、调用方法。
#include ﹤iostream﹥
using namespace std;
void main( )
{
float a, b;
_________; //函数cha的原型声明
a=12.5;
b=6.5;
float c=_____________; //调用函数cha
cout﹤﹤c﹤﹤endl;
}
float cha(float x,float y)
{
float w;
w=x-y;
return w;
}
下面程序的运行结果如下:
This is line1
This is line2
This is line3
将下列程序补充完整,答案写在答题纸上。源程序如下:
#include ﹤iostream﹥
#include _________
using namespace std;
void main( )
{
fstream fin, fout;
fout.open("my.txt", ios:: out);
if(!fout.is_open( ))
return;
for(int i=0; i﹤3; i=i+1)
fout﹤﹤"This is line"﹤﹤i+1﹤﹤endl;
fout.close( );
fin.open("my.txt", ios:: in);
if(! fin.is_open( ))
return;
char str[100];
while(_________)
{
fin.getline(str,100);
cout﹤﹤str﹤﹤endl;
}
fin.close( );
}
#include ﹤iostream﹥
#include ﹤fstream﹥
using namespace std;
class complex
{
public:
int real:
int imag;
complex(int r=0, int i=0)
{
real=r;
imag=i;
}
};
complex operator+(_________,complex&b)
{
int r=a.real+b.real;
int i=a.imag+b.imag;
return _________;
}
void main( )
{
complex x(1, 2), y(3, 4), z;
z=x+y;
cout﹤﹤z.real﹤﹤"+"﹤﹤z.imag﹤﹤"i"﹤﹤endl;
}
#include ﹤iostream﹥
using namespace std;
class base
{
private: int x;
public: base(int a){x=a;}
int get( ){return x:}
void showbase( ) {cout﹤﹤"x="﹤﹤x﹤﹤endl; }
};
class Derived: public base
{private: int y;
public: Derived(int a, int b): base(a) {y=b; }
void showderived( )
{cout﹤﹤"x="﹤﹤get( )﹤﹤",y="﹤﹤y﹤﹤endl; }
};
void main( )
{
base b(3);
Derived d(6, 7);
b.showbase( );
d.showderived( );
_________;
b.showbase( );
_________;
b1.showbase( );
base * pb=&b1;
pb-﹥showbase( );
d.showderived( );
b.showbase( );
}
输出结果如下: x=3 x=6,y=7 x=6 x=6 x=6 x=6,y=7 x=6
完成下面类中的成员函数的定义。
class point
{
private:
int m, n;
public:
point(int, int);
point(point&);
};
point:: point(int a, int b)
{
m=a;
_________=b;
}
point::point( _________ )
{
m=t.m;
n=t.n;
}
#include ﹤iostream.h﹥
class test1{
private: int x;
public: test1( ){x=2;}
void set(int a){x=a;}
void get(){cout﹤﹤x﹤﹤endl;}
};
class test2{
private: int x;
public: test2( ){x=3;}
void set(int a){x=a;}
void get( ){cout﹤﹤x﹤﹤endl;}
};
class test: public test1, public test2. {
private: int x;
public: void set(int a){x=a;}
void gettest( ){cout﹤﹤x﹤﹤endl;}
};
main( ) {
test a; a.get( );
}
#include ﹤iostream.h﹥
class f{
private: float x,y;
float get( ){return x+y;}
public:f1(float a,float b){x=a;y=b;}
};
main( ) {
f a;
a.f1(1, 3.8);
cout﹤﹤a.get( )﹤﹤endl;
}
2005年初级经济师考试《旅游经济专
初级旅游经济师试题及答案一
初级旅游经济师试题及答案二
2005年初级经济师考试《邮电经济专
初级经济师试题及答案1(邮电经济)
初级经济师试题及答案1(保险经济)
初级经济师试题及答案2(邮电经济)
初级经济师试题及答案2(保险经济)
初级经济师试题及答案3(保险经济)
2014年经济师初级考试真题《建筑经