题目内容 (请给出正确答案)
[主观题]

若有以下程序:#include <iostream>using namespace std;class point{private: int x, y;public:

若有以下程序: #include <iostream> using namespace std; class point { private: int x, y; public: point () { x=0; y=0; } void setpoint(int x1,int y1) { x=x1; y=y1;

A.12,12

B.5,5

C.12,5

D.5,12

答案
D
解析:本题考核对象指针的定义与使用。分析程序:程序首先定义一个类point。类point中有两个私有成员,整型变量x和y,还有两个公有成员函数setpoint(intx1,inty1)和dispoint()。函数setpoint()用来设置私有成员x和y的值,而函数dispoint()用来显示私有成员x和y的值。主函数中,首先定义了类point的指针对象p,并申请了内存空间,然后调用对象p中公有成员setpoint给对象p中的私有成员x和y赋值,然后调用成员函数dispoint显示x和y的值。由此可知,最后输出的值应该是5,12。
如搜索结果不匹配,请 联系老师 获取答案
您可能会需要:
您的账号:,可能会需要:
您的账号:
发送账号密码至手机
发送
更多“若有以下程序:#include <iostream>usin…”相关的问题

第1题

以下程序的执行结果是【】。 include <iostream.h> include <fstream.h> include <stdlib.h> int ma

以下程序的执行结果是【 】。

include <iostream.h>

include <fstream.h>

include <stdlib.h>

int main()

{

fstream outfile, infile;

outfile.open("D:\\text.dat",ios::out);

if(!outfile)

{

cout<<"text.dat can't open"<<end1

点击查看答案

第2题

有以下程序:#include<iostream.h>#include<iomanip.h>void main(){cout.fill('*');cout.width(10

有以下程序: #include<iostream.h> #include<iomanip.h> void main() { cout.fill('*'); cout.width(10); cout,<setiosflags(ios::left)<<123.45<<endl; } 程序执行后的输出结果是()

A.****123.45

B.**123.45**

C.123.45****

D.***123.45*

点击查看答案

第3题

以下程序的执行结果是_______。 include<iostream.h> include<fstream.h> include<stdlib.h> void

以下程序的执行结果是_______。

include<iostream.h>

include<fstream.h>

include<stdlib.h>

void main()

{

char ch:

fstream file:

file.open("abc.dat",ios::out1ios::inlios::binary);

if(! file)

{

cout<<“abc.dat文件不能打开”<<endl:

abort

点击查看答案

第4题

有以下程序: include<iostream.h> include<fstream.h> include<stdlib.h> intmain() {fstreamfil

有以下程序:

include <iostream.h>

include <fstream.h>

include <stdlib.h>

int main()

{

fstream filel,file2;

char line[100];

filel.open("source.txt",ios::in);

if(!file1)

{

cout<<"Can't open file source.txt!"<<end1;

abort();

}

file2.open("dest.txt",ios::out);

if(!file2)

{

cout<<"Can't open file dest.txt!"<<end1;

abort();

}

while(!file1.eof())

{

filel.getline(1ine,100);

file2<<line;

file2<<end1;

}

filel.close();

file2.close();

return 0;

}

此程序实现的功能是【 】。

点击查看答案

第5题

若有以下程序,执行后输出结果是 。 include int f(); }
点击查看答案

第6题

有以下程序:include<iostream>include<fstream>using namespace std;int main(){fstream file;fi

有以下程序:

include<iostream>

include<fstream>

using namespace std;

int main()

{

fstream file;

file.open("abc.txt", ios :: in);

if (!file )

{

cout<<"Can not open abc.txt"<<end1;

abort();

}

char buf[ 80 ];

int i = 0;

while (!file.eof())

{

file.getline(buf,80);

i++;

}

cout<<"Lines :"<<i<<end1;

file.close();

return 0;

}

程序实现的功能是【 】。

点击查看答案

第7题

阅读以下程序 #include<fstream.h> void main() { ifstream infile; ofstream outfile; fstream

阅读以下程序

#include<fstream.h>

void main()

{

ifstream infile;

ofstream outfile;

fstream iofile;

iofile.open("a.txt",ios::in);

iofile.close();

iofile.open("b.txt",ios::out);

}

下列描述错误的是

A.对象infile只能用于文件输入操作

B.对象outfile只能用于文件输出操作

C.对象iofile在文件关闭后,不能再打开另一个文件

D.对象iofile可以打开一个文件同时进行输入和输出

点击查看答案

第8题

阅读以下程序# include<fstream. h>void main(){ifstream infile;ofstream outfile;{stream iofi

阅读以下程序# include<fstream. h>void main(){ifstream infile;ofstream outfile;{stream iofile;iofile. open("a. txt", ios:: in);iofile. close();iofile. open('b. txt" ,ios: :out):....}下列描述错误的是

A.对象infile只能用于文件输入操作

B.对象outfile只能用于文件输出操作

C.对象iofile在文件关闭后,不能再打开另一个文件

D.对象iofile可以打开一个文件同时进行输入和输出

点击查看答案

第9题

若有以下程序:#include<iostream>using namespace std;int main(){ int a=3; cout<<(a+=a-=a+A)

若有以下程序: #include <iostream> using namespace std; int main() { int a=3; cout<<(a+=a-=a+A) <<end1; return 0; } 程序执行后的输出结果是()。

A.-6

B.12

C.0

D.-12

点击查看答案

第10题

若有以下程序:#include <iost ream>using namespace std;class A{private: int a;public: A(int

若有以下程序: #include <iost ream> using namespace std; class A { private: int a; public: A(int i) { a=i; } void disp () { cout<<a<<", "; } }; class B { private:

A.10,10,10

B.10,12,14

C.8,10,12

D.8,12,10

点击查看答案

第11题

若有以下程序: include <iostream> using namespace std; int main() {char str[10];cin>>str;co

若有以下程序:

include <iostream>

using namespace std;

int main()

{

char str[10];

cin>>str;

cout<< str<<end1;

return 0;

}

当输入为:

This is a program!

那么执行程序后的输出结果是【 】。

点击查看答案
发送账号至手机
获取验证码
发送
温馨提示
该问题答案仅针对搜题卡用户开放,请点击购买搜题卡。
马上购买搜题卡
我已购买搜题卡, 登录账号 继续查看答案
重置密码
确认修改
温馨提示
每个试题只能免费做一次,如需多次做题,请购买搜题卡
立即购买
稍后再说
警告:系统检测到您的账号存在安全风险

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

微信搜一搜
赏学吧
点击打开微信
警告:系统检测到您的账号存在安全风险
抱歉,您的账号因涉嫌违反赏学吧购买须知被冻结。您可在“赏学吧”微信公众号中的“官网服务”-“账号解封申请”申请解封,或联系客服
微信搜一搜
赏学吧
点击打开微信