请将下面的程序补充完整,使得程序输出“飘是张娜的书”。
include
using namespace std
class Book{
public:
Book(char*str)|strcpy(title,str);
______void Printlnfo(){cout<<title<<endl;}
protected:
char title[50];
};
class MyBook:public Book{
public:
MyBook(char*s1,char*S2=“张娜”):
______strcpy(owner,s2);}
virtual void PrintInfo(){cout<<title<<“是”<<owner<<“的书”<<endl;}
private:
charowner[10];
};
int main(){
Book*ptr=new MyBook(“飘”);
ptr->Printlnfo();
return 0;
}
第1题:
请将下列程序的横线处补充完整,使得输出结果为bbaa
include<iostream>
using namespace std;
class A{
public:
______{cout<<"aa";}
};
class B:public A{
public:
~B(){cout<<"bb";}
};
int main(){
B*p=new
第2题:
请将如下程序补充完整,使得输出结果为:bbaa。
include<iostream>
using naluespace std;
class A{
public:
______{eout<<"aa";}
};
class B:public A{
public:
~B( ){eont<<"bb";}
};
int ulain( ){
B*P=new B;
delete P;
return 0;
}
第3题:
已知如下程序的输出结果是23,请将画线处缺失的部分补充完整。
include <iostream>
using namespace std;
class MyClass {
public:
void Print() const { cout << 23; }
};
int main() {
MyClass* p = new MyClass();
【 】.Print();
return 0;
}
第4题:
下列程序的输出结果为2,请将程序补充完整。
include<iostream>
using namespace std;
class Base
{
public:
______void fun(){cout<<1;}
};
class Derived:public Base
{
public:
void fun(){cout<<2;}
};
int main()
{
Base*p=new Derived;
p->fur();
delete p;
return 0;
}
第5题:
下列程序的输出结果为2,请将程序补充完整。
include <iostream>
using namespaee std;
class Base{
public:
______void fun( ){cout<<1;}
};
class Derived:public Base{
public:
void fun( ){cout<<2;}
};
int main( ){
Base*P=new Derived:
p->fun( );
delete P;
return 0;
}