改正后程序输出结果为public,class
#include
using namespace std;
void main(){
char*a[5]={"new","class","double","main","public"};
char*p1,*p2;
p1=p2=a[0];
for(int i=;i<5;i++){
if(stremp(a[i],p1)<0)pl=a[i];
if(stremp(a[i],p2)<0)p2=a[i];
}
cout< }
声明一个交通工具(vehicle)基类,具有maxspeed、weight成员变量,run stop成员函数(简单输出提示“正在行进”,“停止”),同时编写vehicle类的构造函数和析构函数由此派生出自行车类(bicycle)、汽车类(motorcar),自行车类有高度(height)属性,汽车(motorcar)类有座位数(seatnum)。从bicycle和motorear派生出摩托车类(motorcycle)在继承过程中注意把vehicle设置为虚基类。
完成下面类中成员函数的定义。
#include
#include
using namespace std;
class str
{private:
char*st;
public:
str(char*a){set(a);}
str&operator=(__________){
delete st;
set(a.st);
return*this;}
void show(){cout< ~str(){delete st;} void set(char*s) //初始化 st {_____________; strepy(st,s); } }; void main() {str s1"he"),s2("she"); s1show(),s2show(); s2=s1; s1show(),s2show(); }
#include
#include
struct Worker
{char name[15];//姓名
int age;//年龄
float pay;//工资};
void main(){
Worker x;char*t="LiWei";
int d=28;float f=9000;
strcpy(x.name,t);
x.age=d;x.pay=f;
cout< }
.#include
using namespace std;
class B
{
public:
start(){cout<"B::s() called.\n";}
virtual~B(){cout<<"B::~start()called.\n";}
};
class E:public B
{
public:
E(int i){
cout<<"E::E()called.\n";
buf=new char[i];}
virtual~E()
{
delete[]buf;
cout<<"E::~E()called.\n";
}
private:
char*buf;
};
void fun(B*a)
cout<<"fun()called.\n";
delete a;
}
void main()
{
B*a=new E(15);
fun(a);
}
用带有默认参数的函数实现求前两个及三个正整数中的最大数。
#include
using namespace std;
int main()
{int max(int a,int b,int c=0);
int a,b,c,m1,m2;
cin>>a>>b>>C:
____________
m2=max(a,b);__________
cout<<"a,b,c三个正整数中的最大数为:"< cout<"a,b两个正整数中的最大数为:"< return 0; } intmax(int a,int b,int c) {if(b>a)a=b; ____________ return a; }
程序实现大写字母转换成小写字母。
#include
void main()
{char a ;
______________;
cin>>a;
if(______________)
a=a+i:
cout<
}
程序完成后的运行结果为:DERIVEDBASE
#include
class BASE{
public:
~BASE(){__________}
};
class DERIVED:public BASE{
public:
~DERIVED(){cout<<"DERIVED";}
};
void main()
{__________}
程序完成后的运行结果为:*$*$#
#include
using namespace std;
int main()
{int i;
for(i=3;i<=6;i++)
{if(i%3)___________;
else continue;
___________
cout<<"#\n";
return 0;
}
#include
using namespace std;
class CTest
{private:
int x;
public:
CTest(int x)
{this->x=x;}
int getX()
{retunx;}
};
int main()
{const CTest obj(5);
cout< retum0; }
下面的程序在VC6.0上编提示error C2440: 'type cast' :cannot convert from 'class Complex'to 'float',No user-defined-conversion operator available that can perform. this conversion
#include
using namespace std;
class Complex{
public:
Complex(float r=0,float i=0)
{real=r;imag=i;}
void print()
{cout<'('< private: float real,imag; }; int main() {Complex a(2.2f,4.4f); a.print(); cout< return 0; }
2005年初级经济师考试《旅游经济专
初级旅游经济师试题及答案一
初级旅游经济师试题及答案二
2005年初级经济师考试《邮电经济专
初级经济师试题及答案1(邮电经济)
初级经济师试题及答案1(保险经济)
初级经济师试题及答案2(邮电经济)
初级经济师试题及答案2(保险经济)
初级经济师试题及答案3(保险经济)
2014年经济师初级考试真题《建筑经