以下程序的运行结果是();cout’;}
A.x=2500, y=400, z=1000
B.x=50, y=20, z=0
C.x=1000, y=400, z=1000
D.x=1000, y=20, z=0
- · 有3位网友选择 B,占比33.33%
- · 有3位网友选择 D,占比33.33%
- · 有2位网友选择 C,占比22.22%
- · 有1位网友选择 A,占比11.11%
A.x=2500, y=400, z=1000
B.x=50, y=20, z=0
C.x=1000, y=400, z=1000
D.x=1000, y=20, z=0
include <iostream>
include <string>
using namespace std;
class Y;
class X
{
int x;
char *strx;
public:
X(int a, char *str)
{
x=a;
strx=new char[strlen(str)+1]
strcpy (strx,str);
}
void show(Y &ob);
};
class Y
{
prlvate:
int y;
char *stry;
public:
Y(int b,char *str)
{
y=b;
stry=new char[strlen(str)+1];
strcpy(stry,str);
}
friend void X::show(Y &ob);
};
void X::show{Y &ob)
{
cout<<strx<<",",
cout<<ob.stry<<endl;
}
int main{
{
X a (10, "stringX");
Y b (20, "stringY");
a. show (b);
renurn 0;
}
include<iostream.h>
class base
{
public:
virtual void who(){cout<<"base class"<<endl:}
};
class derrvel:public base
{
public:
void who(){cout<<"derivel class"<<endl:}
};
class derive2;public base
{
public:
void who() {cout<<"derive2 class"<<endl;}
};
void main()
{
base obj1,*P;
derive1 obj2;
derive2 obj3:
p=&obj1;
p->who();
p=&obj2:
p->who();
p=&obj3;
p->who();
}
A.5,2,3
B.-5,-12,-7
C.-5,-12,-17
D.5,-2,-7
#include
void print(double a)
{
cout$amp;}
void print(int a,int B)
{
cout$amp;}
void main()
{
print(1.2);
cout$amp;print(3,4);
}
A.1.2 34
B.2.2 34
C.1.2 43
D.2.2 43
sub(intx,inty,int*z)
{
*z=y-x;
}
voidmain()
{
inta,b;
sub(10,5,&a);
sub(7,a,&b);
cout<
}
A.5,2
B.-5,-2
C.-5,-12
D.5,-2
为了保护您的账号安全,请在“简答题”公众号进行验证,点击“官网服务”-“账号验证”后输入验证码“”完成验证,验证成功后方可继续查看答案!