题目详情
当前位置:首页 > 职业培训考试
题目详情:
发布时间:2024-07-31 21:40:50

[单项选择]对于下面程序,选项正确的是( )。
#include<iostream>
using namespace std;
class point
public:
void setpoint(unsigned, unsigned);
void getpoint(void);
private:
unsigned x;
unsigned y;

void point::setpoint(unsigned x, unsigned y)

point::x=x;
point::y=y;

void point::getpoint(void)
cout<<"x:"<<x<<" "<<"y:"<<y<<endl;
void main(void)

point p1,*p2;p2=π
p1.setpoint(20,10);
p1.getpoint( );
p2->setpoint(1,2);
p2->getpoint( );

A. 该程序编译正确,能输出正确结果
B. 该程序中 setpoint() 形式参数不应为x、y,这样与程序体中的x、y其实是一个变量了
C. 该程序中的 setpoint() 程序体中的“point::x、point::y”应该改为x、y
D. 错误在于主函数中的“p2=&p1;”上,应该改为p2=p1;

更多"对于下面程序,选项正确的是( )。 #include<iostre"的相关试题:

[单项选择]对于下面程序,选项正确的是( )。
#include<iostream>
using namespace std;
class point
public:
void setpoint(unsigned, unsigned);
void getpoint(void);
private:
unsigned x;
unsigned y;

void point::setpoint(unsigned x, unsigned y)

point::x=x;
point::y=y;

void point::getpoint(void)
cout<<"x:"<<x<<" "<<"y:"<<y<<endl;
void main(void)

point p1,*p2;p2=π
p1.setpoint(20,10);
p1.getpoint( );
p2->setpoint(1,2);
p2->getpoint( );

A. 该程序编译正确,能输出正确结果
B. 该程序中 setpoint() 形式参数不应为x、y,这样与程序体中的x、y其实是一个变量了
C. 该程序中的 setpoint() 程序体中的“point::x、point::y”应该改为x、y
D. 错误在于主函数中的“p2=&p1;”上,应该改为p2=p1;
[填空题]下面程序的运行结果是 【8】 #include <iostream> using namespace std; int fun(int n) { static int m = 2; m=m+n; return m; } int main ( ) { int a = 3, b = 4; int x; x = fun( a ); x = fun( b ); cout<<x<<end1; return O; }
[填空题]下面程序执行的结果是 【14】 #include<iostream> using namespace std; class A{ public: static int x; A(inty){cout<<x+y;} }; int A::x=2; void main( ){ A a(5); }
[填空题]下面程序的输出结果是 【13】
#include <iostream>
using namespace std;
class A

int a, b;
public:
A( )

a = b = 0;

A(int aa, int bb ) : a(aA) , b(bB)

cout <<"a="<<a<<","<<"b="<<b<<",";

~A( )

cout<<"D";
;
int main ( )

A x, y(2, 3);
return 0;

[填空题]下面程序的输出结果是 【15】
#include <iostream>
using namespace std;
class base

protected:
int a;
public:
base( )cout<<"0":
;
class basel: virtual public base

public:
base1( ) cout<<"1";
;
class base2 : virtual public base

public:
base2( )cout<<"2";
;
class derived : public base1,public base2

public:
derived ( ) cout<<"3";

int main ( )

derived obj;
cout<<end1;
return 0;

[填空题]下面程序的输出结果为 【7】 。 #include<iostream> using namespace std; void initialize (int print No,int state=0); void initialize(int printNo=1,int state); int main( ) { initialize( ); retum 0; } void initialize (int printNo,int state) { cout<<printNo<<","<<state<<end1; }
[填空题]下面程序的打印结果是 【11】
#include <iostream>
using namespace std;
class Base

public:
Base(int x)

a=x;

void show( )

cout<<a;

private:
int a;
;
class Derived : public Base

public:
Derived(int i) :Base(i+1) ,b(i)
void show( )

cout<<b;

private:
int b;
;
int main ( )

Base b(5) , *pb;
Derived d(1);
pb=&d;
pb->show( );
return 0;

[填空题]下面程序输出的结果是 【11】
#include <iostream>
using namespacc std;
class A
public:
void show( )tout<<"A!";
;
class B: public A
public:
virtual void show( )cout<<"B!";
;
class C: public B
public:
virtual void show( )cout<<"C!";
;
void show_info(A *i)i->show( );
void main( )
A ia;B ib;C ic;show_info(&i
  • a); show_info(&i
  • b);show_info(&i
  • c);

[填空题]下面程序输出的结果是 【10】
#include <iostream>
using namespace std;
class A
public:
virtual void show( ) cout<<"A!";
;
class B: public A
public:
void show( ) cout << "B!";
;
class C: public B
public:
void show( )cout << "C!";
;
void show_info(A &i) i. show( );
void main( )
A ia; B ib; C ic; show_info(i
  • a);show_info(i
  • b); show_info(i
  • c);

[填空题]下面程序的输出结果是 【8】 。 #include<iostream> using namespace std; int x; void funA(int&,int); void funB(int,int&); int main( ) { int first; int second=5; x=6; funA(first,seconD) ; fimB(first,seconD) ; cout<<first<<" "<<second<<" "<<x<<end1; return 0; } void funA(int &a,int B) { int first; first=a+b; a=2*b; b=first+4; } void funB(int u,int &v) { int second; second=x; v=second+4; x=u+v; }
[填空题]下面程序执行的结果是 【15】
#include <iostream>
using namespace std;
void main( )
int sum=0;
int array[6]=1,2,3,4,5,6;
int *p;
p=&array[0];
for(int i=0;i<6;i++)
sum=sum+*p;
p++;

cout<<sum;

[填空题]执行下面程序输出的是 【15】
#include <iostream>
using namespace std;
template <typename T>
T total(T *data)
Ts=0;
while( *data) s+=*data++;
return s;

int main( )
int s[]=1,3,5,7,0,2,4,6,8;
cout<<total(s);
return 0;

[填空题]下列程序的输出结果是 【13】 #include<iostream> using namespace std; template<typenameT> Tfun(Ta,TB) {return (a<=B) a:b;} int main ( ) { cout<<fun(3,6)<<’,’<<fun(3.14F,6.28F)<<end1; return 0; }
[填空题]下列程序的输出结果是 【9】 。 #include<iostream> using namespace std; int main( ){ int i=3; int &r=i; r=5; cout<<i<<endl; return 0; }
[填空题]以下程序的输出结果是 【10】
#include <iostream>
using namespace std;
int main( )

char S[ ]="abcdef";
s[3]=’\0’;
cout<<s<<end1;
return 0;

我来回答:

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

订单号:

截图扫码使用小程序[完全免费查看答案]
请不要关闭本页面,支付完成后请点击【支付完成】按钮
恭喜您,购买搜题卡成功
重要提示:请拍照或截图保存账号密码!
我要搜题网官网:https://www.woyaosouti.com
我已记住账号密码