若有以下程序:
include <iostream>
using namespace std;
class sample
{
int x;
public:
sample(){}
void setx(int i)
{
x=i;
}
friend iht fun(sample B[],int n)
{
int m=0;
for{int i=0;i<n;i++)
if(B[i].x>m)
m=B[i].x;
return.m;
}
};
int main ( )
{
sample A[10];
int arr[]={90,87,42,78,97,84,60,55,78,65};
for(int i=O;i<10;i++)
A[i].setx(arr[i]);
cout<<fun(A, 10)<<end1;
return 0;
}
该程序运行后的输出结果是【 】。
第1题:
下列程序的运行结果是【 】。
include<iostream, h>
class Sample
{
int a;
public:
Sample(int aa=0) {a=aa;}
~Sample() {cout<<"Sample="<<a<<;}
class Derived: public Sample
{
int b;
public:
Derived(int aa=0, int bb=0): Sample(aa) {b=bb;}
~De rived() {cout <<"Derived="<<b<<'';}
void main()
{
Derived dl (9)
}
第2题:
有以下程序: #include<iostream> using namespace std; class sample { private: int x; public: sample(int A) { x=a; friend double square(sample s); }; double square(sample s) { return S.X*S.K; } int main() { sa
A.20
B.30
C.900
D.400
第3题:
若有以下程序: #include <iostream> using namespace Std; class sample { int i; publiC: sample(){} void setvalue(int m) { i=m; } void fun(int m) { i+=m; } void disp() { cout<<i<<end1; } }; int main() { sample *ps; ps=new sample; ps->setvalue(20); ps->fun(5); ps->disp(); return 0; } 程序运行后,输出的结果是( )。
A.15
B.20
C.25
D.30
第4题:
以下程序的执行结果是【 】。
include<iostream. h>
class Sample
{
public:
int x:
int y;
void disp()
{
cout<<"x="<<x<<",y="<<y<<end1;
}
};
void main()
{
int Sample:: ** pc;
Sample s;
pc=& Sample: :x;
s.*pc=10;
pc:=&Sample: :y;
s.*pc=20;
s.disp();
}
第5题:
若有以下程序:
include <iostream>
using namespace std;
class Sample
{
private:
const int n;
public:
Sample(int i) :n(i) {)
void print()
{
cout<<"n="<<n<<end1;
}
};
int main()
{
sample a(10);
a.print();
return 0;
}
上述程序运行后的输出结果是【 】。