题目详情
当前位置:首页 > 职业培训考试
题目详情:
发布时间:2023-10-23 10:39:09

[填空题]使用VC++6.0打开考生文件夹下的源程序文件3.cpp,其中定义r用于表示个人基本信息的类PInfo,但类PInfo的定义并不完整。请按要求完成下列操作,将类PInfo的定义补充完成:
(1)定义私有数据成员bloodType用于表示血型,血型为char型的数据。请在注释1之后添加适当的语句。
(2)完成构造函数的定义,要求具有默认值,默认值为身高175,体重70,血型A。请在注释2之后添加适当的语句。
(3)完成类PInfo外成员函数SetInfo的定义。请在注释3之后添加适当的语句。
(4)在主函数中调用成员函数SetInfo,把对象d2的3个私有数据成员分别设定为身高170,体重64,血型B。请在注释4之后添加适当的浯句。
注意:除在指定位置添加语句之外,请不要改动程序中的其他内容。
试题程序:
#include<iostream.h>
class PInfo

private:
int height;
int weight;
//********1********
public:
//********2********
:height(ht),weight(wt),bloodType(bt);
PInfo(PInfo &h1):height(h1.height),
weight(h1.weight),bloodType(h1.bloodType)
int GetHeight( )

return height;

int GetWeight( )

return weight;

int GetBloodType( )

return bloodType;

void SetInfo(int ht,int wt,char bt);
void Display( );

//********3********

height=ht;
weight=wt;
bloodType=bt;

更多"使用VC++6.0打开考生文件夹下的源程序文件3.cpp,其中定义r用"的相关试题:

[填空题]使用VC++6.0打开考生文件夹下的源程序文件3.cpp,其中定义r用于表示个人基本信息的类PInfo,但类PInfo的定义并不完整。请按要求完成下列操作,将类PInfo的定义补充完成:
(1)定义私有数据成员bloodType用于表示血型,血型为char型的数据。请在注释1之后添加适当的语句。
(2)完成构造函数的定义,要求具有默认值,默认值为身高175,体重70,血型A。请在注释2之后添加适当的语句。
(3)完成类PInfo外成员函数SetInfo的定义。请在注释3之后添加适当的语句。
(4)在主函数中调用成员函数SetInfo,把对象d2的3个私有数据成员分别设定为身高170,体重64,血型B。请在注释4之后添加适当的浯句。
注意:除在指定位置添加语句之外,请不要改动程序中的其他内容。
试题程序:
#include<iostream.h>
class PInfo

private:
int height;
int weight;
//********1********
public:
//********2********
:height(ht),weight(wt),bloodType(bt);
PInfo(PInfo &h1):height(h1.height),
weight(h1.weight),bloodType(h1.bloodType)
int GetHeight( )

return height;

int GetWeight( )

return weight;

int GetBloodType( )

return bloodType;

void SetInfo(int ht,int wt,char bt);
void Display( );

//********3********

height=ht;
weight=wt;
bloodType=bt;
[简答题]打开考生文件夹,在STUDENTS子文件夹中创建一个名为WANGLING的子文件夹。
2.将考生文件夹中的全部以字母A开头的文件复制到子文件夹WANGLING中。
3.删除SUTDENTS文件夹下PENG子文件夹中的testing文件。
4.将考生文件夹中TEXT文件夹里的test文件的属性设置为“隐藏”和“只读”。
5.将STUDENTS文件夹下的USER-4子文件夹更名为DINGHONG。
[多项选择]请使用“答题”菜单或使用VC6打开考生文件夹proj2下的工程proj2。此工程包含程序文件main.cpp,其中有类AutoMobile(“汽车”)及其派生类Car(“小轿车”)、Truck(“卡车”)的定义,还有主函数main的定义。请在程序中//************found************下的画线处填写适当的代码,然后删除横线,以实现上述类定义。此程序的正确输出结果应为:
车牌号:冀ABC1234品牌ForLand类别:卡车当前档位:0最大载重量:1~
车牌号:冀ABC1234品牌ForLand类别:卡车当前档位:2最大载重量:1~
车牌号:沪XY25678品牌QQ类别:小轿车当前档位:0座位数:5
车牌号:沪XY25678品牌QQ类别:小轿车当前档位:-1座位数:5
注意:只能在画线处填写适当的代码,不要改动程序中的其他内容,也不能删除或移动
//************found************。
//源程序
#include<iostream>
#include <iomanip>
#include <cmath>
using namespace std;
class AutoMobile //"汽车"类
char*brand; //汽车品牌
char*number; //车牌号
int speed; //档位:1、2、3、4、5,空档:0,倒档:-1
public:
A. ~AutoMobile()delete[] brand; delete[] number;
[简答题]请使用“答题”菜单或使用VC6打开考生文件夹proj1下的工程proj1,此工程包含程序文件
main.cpp,其中有类Book(“书”)和主函数main的定义。程序中位于每个//ERROR************found************下的语句行有错,请加以改正。改正后程序的输出应该是:
书名:C++语言程序设计 总页数:299
已把"C++语言程序设计"翻页到第50页
已把“C++语言程序设计"翻页到第51页
已把书合上。
书是合上的。
已把"C++语言程序设计"翻页到第1页
注意:只能修改每个//ERROR************found************下的那一行,不要改动程序中的其他内容。
// 源程序
#include<iostream>
using namespace std;
class Book
char*title;
int num_pages; //页数
int cur_page; //当前打开页面的页码,0表示书未打开
public:
Book(const char*theTitle,int pages):num_pages(pages)
//ERROR************found************
title=new char[strlen(theTitle)];
strcpy(title,theTitle);
cout<<endl<<"书名:"<<title<<"总页数:"<<num_pages;

~Book( )delete[]title;
//ERROR************found************
bool isOpen( ) const return num_pages!=0; //书打开时返回true,否则返回false
int numOfPages( ) const return num_pages; //返回书的页数
int currentPage( ) const return cur_page; //返
[简答题]请使用“答题"菜单或使用VC6打开考生文件夹proj1下的工程proj1。此工程包含程序文件main.cpp。程序中位于每个//ERROR************found************下的语句行有错误,请加以更正。更正后程序的输出应该是:
1958年3月23日比2001年11月5日更早
2001年11月5日比1958年3月23日更晚
2001年11月5日与2001年11月5日是同一日期
注意:只能修改每个//ERROR************found************下的那一行,不要改动程序中的其他内容。
//源程序
#include <iostream>
using namespace std;
class Date
int year;
int month;
int day;
public:
//ERROR************found************
Date(int yyyy, int mm, int dd): yyyy(year),mm(month),dd(day)
bool isLaterThan(Date dt) const //当前日期晚于日期dt时返回true
if(year!=dt.year) return year>dt.year;
if(month!=dt.month) return month>dt.month;
return day>dt.day;

bool isEarlyThan(Date dt) const //当前日期早于日期dt时返回true
if(year!=dt.year) return year<dt.year;
if(month !=dt.month) return month<dt.month;
//ERROR************found************
return day>dt.day;

void showDate( ) const cout<<year<<"年"<<month<<"月"<<day<<"日";<
[多项选择]请使用“答题”菜单或使用VC6打开考生文件夹proj2下的工程proj2。此工程包含一个程序文件main.cpp,其中的Array是一个表示数组的模板类。Array的成员a用于指向存放数据的数组,size表示该数组的大小。此程序的输出结果应为:
8
29,20,33,12,18,66,25,14
66,33
注意:只能在画线处填写适当的代码,不要改动程序中的其他内容,也不能删除或移动//************found************。
//源程序
#include <iostream>
#include <cstdlib>
using namespace std;
template<class Type>
class Array//数组类
Type *a;
int size;
public:
A. for(int i=0; i<size; i++) a[i]=b[i];
B. i>=size)cout<<"下标越界!"<<endl;exit(1);
C. return a[i];;
D. //由x1和x2带回数组a中的两个最大值
E. template<class Type>
F. void Array<Type>::MaxTwo(Type& x1,Type& x2) const //补充完整函数体的内容
G. //将数组a中头两个数据赋值给x1和x2,使得x1>=x2
H. ______(x1=a[0],x2=a[1]):(x1=a[1],x2=a[0]);
I. for(int i=2;i<size; i++)
J. if(a[i]>x1)x2=x1; x1=a[i];
K. else if(a[i]>x2) x2=a[i];
L. void main()
M. int s1[8]=29,20,33,12,18,66,25,14;Array<int> d1(s1,8);
N. int i,a,b;
O. d1.M axTwo(a,b);
P. cout<<d1.Length()<<endl;
Q. for(i=0;i<7;i++) cout<<d1[i]<<",";
R. cout<<d1[7]<<endl;cout<<a<<","<<b<<endl;
[简答题]使用VC6打开考生文件夹下的工程RevProj10。此工程包含一个源程序文件RevMain10.cpp。在该文件中,函数fun的功能是:计算出数组x中的最小值与次最小值,并分别将其与x[0]、x[1]交换。 请改正程序中的错误,使它能得到正确结果。 注意,不要改动主函数,不得删行或增行,也不得更改程序的结构。 源程序文件RevMain10.cpp中的程序清单如下: //RevMain10.cpp #include <iostream> using namespace std; #define N 30 int fun(int *x, int n); int main ( ) { int h[N]={4,7, 6, 5, 1, 7,3, 8,0,2,3}; int i; for (i=0; i<11; i++) cout<<h [i] << " " ; cout <<"/n"; fun(h, 11); for (i=0; i<n; i++) cout<<h [i]<<" "; cout<<’ /n’; return 0; } int fun(int *x, int n) { int i,t; int a1=0, a2=0,min1=32767,min2=32676; /* * * * *FOUND * * * * */ for(i=1;i<n;i++) { if (x [i]<min1) { min2=min1; a2=a1; min1=x [i]; a1=i; } else if (x [i] <min2) { min2=x [i]; a2=i; } } /* * * * *FOUND * * * *
[简答题]使用VC6打开考生文件夹下的工程RevProj11。此工程包含一个源程序文件RevMain11.cpp,但在源程序文件中有错误。请改正程序中的错误,使它能得到正确结果。
注意,不得删行或增行,也不得更改程序的结构。
源程序文件RevMainll.cpp中的程序清单如下:
//RevMainll.cpp
#include<iostream>
using namespace std;
class point

private:
const int color;
int x;
int y;
public:
point(int x,int y,int c)

this->x=x;
this->y=y;
color=c;

void show( )

cout<<"x="<<x<<",y="<<y<<",color="<<color<<end1;


int main( )

const point p(10,10,100);
p.show( );
return 0;

[简答题]使用VC6打开考生文件夹下的工程RevProj12。此工程包含一个源程序文件RevMain12.cpp,但在该程序中有错误。请改正程序中的错误,使它能得到正确结果。
注意:不得删行或增行,也不得更改程序的结构。
源程序文件RevMain12.cpp中的程序清单如下:
//RevMain12.cpp
#include<iostream>
/* * * * FOUND * * * * */
using namespace std;
class test

private:
const int value;
char dep[10];
public:
/* * * * *FOUND* * * * */
test( )

value=0;
strcpy(dep,"m");

/* * * * *FOUND* * * * */
test(int newvalue)

value=newvalue;
strcpy (dep, "m");

/* * * * *FOUND * * * * */
void show( )

cout<<"value= "<<value<<end1;

;
int main ( )

test t1;
const test t2;
t1.show ( );
t2.show( );
return 0;

[简答题]使用VC6打开考生文件夹下的工程RevProj14。此工程包含一个源程序文件RevMain14.cpp,但该程序中类的定义有错误。请改正程序中的错误,使它能得到正确结果。
注意,不要改动main函数,不得删行或增行,也不得更改程序的结构。
源程序文件RevMain14.cpp中的程序清单如下:
//RevMain14.cpp
#include<iostream>
#include<math>
using namespace std;
class Point

private:
double x;
double y;
public:
Point( )
void Point(double x1,double y1)

x=x1;
y=y1;

void setvalue(double x,double y)

x=x;
y=y;

double getx ( )

return x;

double gety( )

return y;

void print( )

cout<<"x="<<x<<",y= "<<y<<end1;

~Point( )
;
class Line

private:
Point p1;
Point p2;
double width;
public:
Line(double x1,double y1,double x2,double y2,double d)
:p1(x1,y1),p2(x2,y2)

width=d;

~Line( )
void displ

我来回答:

购买搜题卡查看答案
[会员特权] 开通VIP, 查看 全部题目答案
[会员特权] 享免全部广告特权
推荐91天
¥36.8
¥80元
31天
¥20.8
¥40元
365天
¥88.8
¥188元
请选择支付方式
  • 微信支付
  • 支付宝支付
点击支付即表示同意并接受了《购买须知》
立即支付 系统将自动为您注册账号
请使用微信扫码支付

订单号:

请不要关闭本页面,支付完成后请点击【支付完成】按钮
恭喜您,购买搜题卡成功
重要提示:请拍照或截图保存账号密码!
我要搜题网官网:https://www.woyaosouti.com
我已记住账号密码