有如下程序:
inClude<iostream>
using namespace std;
class AA
{
public:
viltual void f()
{
cout<<"AA";
}
};
class BB:public AA
{
public:
BB()
{
cout<<"BB";
}
};
class CC:public BB
{
public:
virtual void f()
{
BB::f();
cout<<"CC";
}
};
int main()
{
AA aa,*p;BB bb;CC cc;
p=&cc;
p->f();
return 0;
}
运行后的输出结果【 】。
下列程序的输出结果为【 】。
inelude<iostream. h>
int &max(int &x, int &y)
{return (x>y? x: y); }
void main() {
int n=3, m=12;
max(m, n)++
cout<<"m="<<m<<", n= "<<n<<end1;
}
下面程序的执行结果是【 】。
include<iostream.h>
void main(){
int a=0,b=2,c=0,d=30;
if(a)
d=d-10;
else if(B)
if(!C)
d=15;
else d=20;
cout<< “d=” <<d<<end1;
下面程序中错误之处是 ______。
include<iostream.h>
class A{
private:
int xl;
protected:
int x2;
public:
int x3;
};
class B: public A{
private:
int b1;
protected:
int b2;
public:
int b3;
void disp(){cout<<x1<<b2<<end1;} //A
void set(int i){x3=i;} //B
};
void main()
B bb;
bb. a3=10 //C
bb. b3=10 //D
}
使用VC6打开考生文件夹下的工程test10_1,此工程包含一个源程序文件test10_1.cpp,但该程序运行有问题,请改正程序中的错误,使程序的输出结果为;
class Base
class D1
class D2
class D3
fin Base
源程序文件test10_1.cpp清单如下:
include<iostream.h>
class Base
{
public:
Base(){cout<<"class Base"<<endl;}
void f(){cout<<"f in Base"<<endl;}
};
class D1:virtual public Base
{
public:
D1(){cout<<"class D1"<<endl;}
void f(){cout<<"f in D1"<<endl;}
};
/*********found**********/
class D2:public Base
{
public:
D2(){cout<<"class D2"<<endl;}
/**********found**********/
class D3::public D1,public D2
{
public:
D3(){cout<<"class D3"<<endl;}
};
void main()
{
D3 d;
/**********found************/
d.f();
}
有以下程序:
include <iostream>
using namespace std;
const xnt N=5;
int fun(char *s,char a,int n)
{
int j;
*s=a;j=n;
while(a<s[j])
j--;
return j;
}
int main()
{
char s[N+1];
int k;
长理培训客户端 资讯,试题,视频一手掌握
去 App Store 免费下载 iOS 客户端
点击加载更多评论>>