#include <iostream>
#include <string>
using namespace std;
class Document {
public:
Document() {
}
Document(char* nm);
char* name;
void PrintNameOf();
};
Document::Document(char* nm) {
name = new char[strlen(nm) + 1];
strcpy(name, nm);
};
void Document::PrintName0f() {
cout << name << endl;
}
class Book :public Document {
public:
Book(char* nm, long pagecount);
void PrintNameOf();
private:
long pageCount;
};
Book::Book(char* nm, long pagecount) :
Document(nm) {
pageCount = pagecount;
}
void Book::PrintNameOf() {
cout << "Name Of Book:";
Document::PrintNameOf();
}
int main() {
Document a("Document1");
Book b("Book1", 100);
b.PrintNameOf();
return 0;
}
标签:char,nm,void,5.12,Book,Document,PrintNameOf From: https://www.cnblogs.com/zjm921/p/17396230.html