给出下面程序的输出结果。
#include ﹤iostream﹥
#include ﹤string﹥
using namespace std;
class Book {
char*title;char*author;
int numsold;
public:
Book( ){ }
Book(const char*str1, const char*str2, const int num) {
int len=strlen(str1);
title=new char[1en+1];
strcpy(title, strl);
len=strlen(str2);
author=new char[1en+1];
strcpy(author, str2);
numsold=num; }
void sethook(const char * strl, const char * str2, const int num) {
int len=strlen(strl);
title=new char[1en+1];
strcpy(title, strl);
len=strlen(str2);
author=new char[1en+1];
strcpy(author, str2);
numsold=num;
}
~Book( ) {
delete title;
delete author;
}
void print(ostream& output) {
output﹤﹤"书名:"﹤﹤title﹤﹤endl;
output﹤﹤"作者:"﹤﹤author﹤﹤endl;
output﹤﹤"月销售量:"﹤﹤numsold﹤﹤endl;}
};
void main( ) {
Book obj1("数据结构","严蔚敏",200),obj2;
obj1.print(cout);
obj2.setbook("C++语言程序设计","李春葆",210);
obj2.print(cout);
}
订单号:
遇到问题请联系在线客服
订单号:
遇到问题请联系在线客服