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