使用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;
执行如下程序后的输出结果是【 】。
include <iostream>
include <fstream>
using namespace std;
int main ()
{
char s[25];
ofstream fl("data.txt");
f1<<"C++ Programming";
f1.close ();
ifstream f2 ("data.txt");
以下程序的执行结果是______。
include<iostream.h>
class Sample
{
int n;
public:
Sample() {}
Sample (int i (n=i;)
void add (Sample &s1,Sample s2)
{
this->n=sl.n+=s2.n;
}
void disp() {cout<<" n="<< n <<end1:}
}
void main ()
如下程序的输出结果是______。
include<iostream>
using namespace std;
class Pet{
char name[10];
public:
Pet(char*nanle){strcpy(this->name,name);}
const char*getName()const{return name;}
virtual void call()eonst=0;
};
class Dog:public Pet{
public:
Dog(char*name):Pet(name){ }
void call()eonst{cout<<"汪汪叫";}
};
class Cat:public Pet{
public:
Cat(char*name):Pet(name){ }
void call()const{eout<<"喵喵叫";}
};
int main(){
Pet*petl=new Dog("哈克"),*pet2=new Cat("吉米");
eout<<petl->getName();petl->call();eout<<endl;
cout<<pet2->getName();pet2->call();eout<<endl;
return 0;
}
有如下程序段:
intx=1,y=2,z=3;
x=x^z:
y=y^z;
z=x^y:
cout<<x<<y<<z;
这个程序段的输出结果是______。
长理培训客户端 资讯,试题,视频一手掌握
去 App Store 免费下载 iOS 客户端
点击加载更多评论>>