填空题

请将下面的程序补充完整,使得程序输出"飘是张娜的书"。#include <iostream> using namespace std; class Book{ public: Book(char *str){ strcpy(title,str); } () void PrintInfo(){ 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: char owner[10]; }; int main(){ Book *ptr=new MyBook("飘"); ptr->PrintInfo(); return 0; }

发布于 2020-12-25 23:01:49

登录后免费查看答案
关注者
0
被浏览
66
知识点
面圈网VIP题库

面圈网VIP题库全新上线,海量真题题库资源。 90大类考试,超10万份考试真题开放下载啦

去下载看看