下面关于对象概念的描述中错误的是( )
定义一个生日类,数据成员有年、月、日。定义一个人员类,数据成员有姓名、性别、生日。人员类中的生日是生日类的对象,两个类都有构造函数和显示函数。在主函数中声明一个人员类对象,屏幕显示其数据。
#include ﹤iostream﹥
using namespace std;
void sort( int L[ ], int n)
{
int i, k, flag, temp;
flag=n-1;
while( flag﹥0)
k=flag -1;
flag=0;
for(j=0; j﹤=k; j++)
if(L[j]﹥L[j+1])
temp=L[j];
L[j]=L[j+1];
L[j+1]=temp;
flag =j;
}
void main( )
int array[4]={7,2,3,4};
sort( array, 4);
cout ﹤﹤"The sorted numbers:";
for(int i=0; i﹤4; i++)
cout ﹤﹤ array[i];
class x
{protected: int a;public: x( ) {a=1; }
};
class x1;
virtual public x
public:
x1( )
{a+=1; cout﹤﹤"x1: "﹤﹤a﹤﹤","; }
class x2:
public:x2( )
{a+=2; cout﹤﹤"x2: "﹤﹤a﹤﹤","; }
class y:
public x1,
public x2
public:y( )
{ cout ﹤﹤"y: "﹤﹤a﹤﹤ endl; }
y obj;
程序运行结果为3
int main( )
int a=16, b=21, m=0;_________
case 0: m++; break;
case 1: m++ ;
switch(b%3)
_________
case 1: m++; break;
cout ﹤﹤m﹤﹤ endl;
return 0;
定义平面上一个点的类point,有双精度型私有数据成员横坐标x和纵坐标y,公有成员函数有写入函数input( )、求原点距离函数distance( )和显示函数show( ),请完成point( )的类图。
程序的运行结果为:12
class Base
int a;Base (int i)
a=i;
class Derived:
public Base
int a;
Derived(int x):
Base(x) { }
void show( )
_________; //输出基类数据成员a的值
void main( }
{_________d. show ( );
class F
double F:: operator( ) (double x, double y) const
retum(x+5)*y;
F f;cout﹤﹤f(1.5, 2.2)﹤﹤endl;
程序在主函数中创建派生类Derived的对象obj,调用f( )函数后输出DBC
virtual void f( )
cout ﹤﹤"B";
Derived( )
cout ﹤﹤"D";
Base:: f( );
cout ﹤﹤"C";
Base *ptr;
Derived obj;
ptr=&obj;
retun 0;
此程序调用 findmax( )函数,返回数组中的最大值。
include ﹤iostream﹥
int findmax (int *a, int n)
int *p, *s;
for(p=a, s=a; p-a﹤n; p++)
if(*P﹤*s) *s=*p;
return(* s);
int x[5]={12,2,8,47};
cout﹤﹤ findmax(x, 5)﹤﹤endl;
int x=15;
while(10﹤x﹤50)
x++;if(x/3)
x ++; break;
cout﹤﹤x﹤﹤endl;
热门试卷
经济师初级(经济基础知识)模拟试卷5
经济师初级经济基础知识(商品经济的基
经济师(初级)工商管理专业知识与实务
初级经济师试题及答案3(公路运输)
经济师初级人力资源管理专业知识与实务
初级经济师《工商专业》全真模拟试卷(
初级经济师《经济基础知识》考前突破试
订单号:
遇到问题请联系在线客服