搜题
网友您好,请在下方输入框内输入要搜索的题目:
搜题
题目内容 (请给出正确答案)
提问人:网友pwb568568 发布时间:2022-01-06
[主观题]

使用VC6打开考生文件夹下的工程test29_3。此工程包含一个test29_3.cpp,其中定义了二维坐标类Coord

inate和三维坐标类ThreeDCoord,其中ThreeDCoord类由Coordinate类public派生,但两个类的定义并不完整。请按要求完成下列操作,将程序补充完整。

(1)定义类Coordinate的保护数据成员x和y,它们都是int型的数据,代表二维坐标的横纵坐标值。请在注释“//**1 **”之后添加适当的语句。

(2)根据类Coordinate定义后的成员函数Display的实现,补充该函数在类Coordinate定义体内的声明,Display为二维坐标类的虚函数。请在注释“//**2**。”之后添加适当的语句。

(3)完成二维坐标类Coordinate的构造函数,将参数a和b分别赋值给数据成员x和y。请在注释“//**3**”之后添加适当的语句。

(4)根据ThreeDCoord类构造函数的声明,补充ThreeDCoord构造函数的实现,参数a和b通过调用基类的构造函数来初始化基类的数据成员x和y,c赋值给数据成员2。请在注释“//**4**”之后添加适当的语句。

输出结果如下;

[1,2]

[3,4,5]

注意:除在指定位置添加语句之外,请不要改动程序中的其他内容。

源程序文件tese9_3.cpp清单如下:

include<iostream.h>

class Coordinate

{protected:

//** 1 **

public:

Coordinate(int a=0, int b=0);

//** 2 **

};

Coordinate::Coordinate(int a, int b)

{

//** 3 **

}

void Coordinate::Display() const

{

cout << '[' << x << ", "<< y << ']' << end1;

}

class ThreeDCoord:public Coordinate

{

int z;

public:

ThreeDCoord(int a=0, int b=0, int c=0);

virtual void Display() const;

};

//** 4 **

void ThreeDCoord::Display() const

{

cout << '[' << x << ", "<< y << ", "<< z << ']' << end1;

}

void main ()

{

Coordinate c(1, 2);

ThreeDCoord t(3, 4, 5);

c.Display ();

t.Display ();

}

简答题官方参考答案 (由简答题聘请的专业题库老师提供的解答)
查看官方参考答案
更多“使用VC6打开考生文件夹下的工程test29_3。此工程包含一个test29_3.cpp,其中定义了二维坐标类Coord”相关的问题
第1题
使用VC6打开考生文件夹下的工程test18_1,此工程包含一个源程序文件(est18_1.cpp,但该程序运行有

使用VC6打开考生文件夹下的工程test18_1,此工程包含一个源程序文件(est18_1.cpp,但该程序运行有问题,请改正程序中的错误,使程序的输出结果如下:

Enter x and y:

-4 -5

xoffset=1

yoffset=1

angle=45

radius=1.41421

源程序文件test18_1.cpp 清单如下:

include <iostream.h>

include <math.h>

class point

{

public:

void set(double ix,double iy)

{

x=ix;

y=iy;

}

double xoffset()

{

return x;

}

double yoffset()

{

return y;

}

double angle ()

{

return (180/3.14159)*atan2(y,x);

}

/**************** found *******************/

inline radius ()

{

return sqrt(x*x+y*y);

}

protected:

double x;

double y;

};

void main()

{

point p;

double x,y;

cout<<"Enter x and y:\n";

cin>>x>>y;

p.set(x,y);

/**************** found *******************/

p.x+=5;

p.y+=6;

/**************** found *******************/

cout<<"xoffset="<<p.xoffset()<<end1;

cout<<"yoffset="<<p.yoffset()<<end1;

cout<<"angle="<<p.angle()<<end1;

cout<<"radius="<<p.radius()<<end1;

点击查看答案
第2题
使用VC6打开考生文件夹下的工程test28_1,此工程包含一个源程序文件test28_1.cpp,但该程序运行有
问题,请改正程序中的错误,使该程序的输出结果为:

5

5

源程序文件test28_1.cpp清单如下:

include <iostream.h>

class A{

public:

/***************** found *****************

static int n=1;

A(){n++;};

~A() (n--;};

};

/***************** found *****************

int n=0;

int main() {

A a;

A b[3];

A *c=new A;

c=&a;

/***************** found *****************

cout<<c.n<<end1;

cout<<A::n<<end1;

return 0;

}

点击查看答案
第3题
使用VC6打开考生文件夹下的工程RevProj3。此工程包含一个源程序文件 RevMain3.cpp。阅读文件中的程
序代码,找出程序中的错误,并改正。

源程序文件RevMain3.cpp清单如下:

//RevMain3.cpp

include<iostream>

using namespace std;

class MyClass{

public:

/* * * * * * * * *found * * * * * * + * * */

void MyClass(int a){ value=a;}

int Max(int x,int y)

{

if(x>y)

return x>y?x:y;

else

return y>value?y:value;

}

/* * * * * * * * *found * * * * * * * * * */

~MyClass(int a)

{

value=a;

}

private:

int value;

};

int main()

{

MyClass my(10);

cout<<my.Max(20,30)<<end1;

return 0;

}

点击查看答案
第4题
使用VC6打开考生文件夹下的工程RevProj4。此工程包含一个源程序文件RevMain4.cpp,但该程序运行有
问题。请改正主函数中的错误,使之输出结果为:

x=20

源程序文件RevMain4.cpp的清单如下:

//RevMain4.cpp

include<iostream>

using namespace std;

class MyClass

{

public:

MyClass(int a)

{

x=a;

}

void setX(int a)

{

x=a;

}

void print()

{

cout<<"x="<<x;

}

private:

int x;

};

int main()

{

const MyClass obj (10);

/ ************found**************/

obj.setX(20);

/ ************found**************/

obj.print();

return 0;

}

点击查看答案
第5题
使用VC6打开考生文件夹下的工程test41_1,此工程包含一个源程序文件test41_1.cpp,但该程序运行有
问题,请改正函数中的错误,使该程序的输出结果为:

7

源程序文件test41_1.cpp清单如下:

include<iostream.h>

class myclass

{

int a, b;

public:

/***************** found *****************/

int sum(myclass x);

void set_ab(int i, int j);

}:

/**************** found ****************/

void myclass:set_ab(int i, int j)

{

a=i;

b=j;

}

int sum (myclass x)

{

/***************** found ***************/

x.a+x.b;

}

void main ()

{

myclass n;

n.set_ab (3, 4);

cout <<sum(n)<<endl;

}

点击查看答案
第6题
使用VC6打开考生文件夹下的工程test6_1,此工程包含一个源程序文件test6_1.cpp,但该程序运行有问
题,请改正程序中的错误,使程序的输出结果如下:

Constructor2

Constructor1

i=0

i=10

Destructor

源程序文件test6_1.cpp清单如下:

include<iostream.h>

class CSample

{

int i;

public;

CSample(){cout<<"Constructorl"<<endl;i=0;)

CSample(int val){cout<<"Constructor2"<<endl;i=val;}

~CSample()(cout<<"Destructor"<<endl;)

void disp();

};

/**********found********/

void disp()

{

cout<<"i=”<<i<<endl;

}

void main()

{

CSample *a,b(10);

/**********found*********/

a->disp();

/**********found*********/

b->disp();

}

点击查看答案
第7题
使用VC6打开考生文件夹下的工程test36_1,此工程包含一个源程序文件test36_1.cpp,但该程序运行有
问题,请改正函数中的错误,使该程序的输出结果为:

2

源程序文件test36_1.cpp清单如下:

include<iostream.h>

class amount;

class coins

{

/***************** found *****************/

enum units {penny, nickel, dime, quarter, half_dollar}

/***************** found *****************/

class amount;

};

class amount

{

/***************** found *****************/

coins:units money;

public:

void setm();

int germ();

};

void amount::setm()

{

money = coins::dime;

}

int amount::getm()

{

return money;

}

int main ()

{

amount ob;

ob.setm();

cout << ob.getm()<<end1;

return 0;

}

点击查看答案
第8题
使用VC6打开考生文件夹下的工程test26_1,此工程包含一个源程序文件test26_1.cpp,但该程序运行有
问题,请改正

函数中的错误,使该程序的输出结果为:

Values are: 1,2 and 3

源程序文件test26_1.cpp清单如下;

include <iostream.h>

class CommonBase

{

public:

int x;

};

/*****************found*****************/

class DeriveCommonA::public CommonBase

{

public:

int y;

};

class DeriveCommonB:public CommonBase

{

public:

int z;

};

/*****************found*****************/

class Overlapping:public DeriveCommonA; public DeriveCommonB

{

public:

void Display()

{

cout<<"Values are: "<<DeriveCommonA::x<<", "<<y<<" and "<<z<<end1;

}

};

int main ()

{

Overlapping ov;

/*****************found*****************/

ov.x=1;

ov.y=2;

ov.z=3;

ov.Display();

return 0;

}

点击查看答案
重要提示: 请勿将账号共享给其他人使用,违者账号将被封禁!
查看《购买须知》>>>
重置密码
账号:
旧密码:
新密码:
确认密码:
确认修改
购买搜题卡查看答案
购买前请仔细阅读《购买须知》
请选择支付方式
微信支付
支付宝支付
点击支付即表示你同意并接受《服务协议》《购买须知》
立即支付
搜题卡使用说明

1. 搜题次数扣减规则:

功能 扣减规则
基础费
(查看答案)
加收费
(AI功能)
文字搜题、查看答案 1/每题 0/每次
语音搜题、查看答案 1/每题 2/每次
单题拍照识别、查看答案 1/每题 2/每次
整页拍照识别、查看答案 1/每题 5/每次

备注:网站、APP、小程序均支持文字搜题、查看答案;语音搜题、单题拍照识别、整页拍照识别仅APP、小程序支持。

2. 使用语音搜索、拍照搜索等AI功能需安装APP(或打开微信小程序)。

3. 搜题卡过期将作废,不支持退款,请在有效期内使用完毕。

请使用微信扫码支付(元)

订单号:

遇到问题请联系在线客服

请不要关闭本页面,支付完成后请点击【支付完成】按钮
遇到问题请联系在线客服
恭喜您,购买搜题卡成功 系统为您生成的账号密码如下:
重要提示:请勿将账号共享给其他人使用,违者账号将被封禁。
发送账号到微信 保存账号查看答案
怕账号密码记不住?建议关注微信公众号绑定微信,开通微信扫码登录功能
警告:系统检测到您的账号存在安全风险

为了保护您的账号安全,请在“简答题”公众号进行验证,点击“官网服务”-“账号验证”后输入验证码“”完成验证,验证成功后方可继续查看答案!

- 微信扫码关注简答题 -
警告:系统检测到您的账号存在安全风险
抱歉,您的账号因涉嫌违反简答题购买须知被冻结。您可在“简答题”微信公众号中的“官网服务”-“账号解封申请”申请解封,或联系客服
- 微信扫码关注简答题 -
请用微信扫码测试
欢迎分享答案

为鼓励登录用户提交答案,简答题每个月将会抽取一批参与作答的用户给予奖励,具体奖励活动请关注官方微信公众号:简答题

简答题官方微信公众号

简答题
下载APP
关注公众号
TOP