双11狂欢大促

盲盒赢 定制羽绒服

开启惊喜盲盒,抽取你的专属好礼

— 惊喜奖品抢先看 —

error LNK2001: unresolved external symbol "public: __thiscall Book::~Book(void)"

pw2156314 pw2156314 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区

/*三、以下是图书类book的定义,但没有类的实现部分的代码,请根据类的定义编写类的实现部分的代码,并编写响应的程序对所定义的类进行测试。
Class book
{
   char *name; //书名
   Char *author; //作者
   Int sale; //销售量
Public
   Book( ); //无参构造函数
   Book(char,char,int);  //有参构造函数
   Void disp( ) //输出数据
   ~book( ); //析构函数
}
*/
#include<iostream>
#include<string.h>
using namespace std;

class Book
{
public:
Book(){name="c_plus_plus",author="T_H_Q",sale=60000;};
Book(string name1,string author1,int sale1):name(name1),
author(author1),sale(sale1){;};
string get_name(){return name;};
string get_author(){return author;};
int get_sale(){return sale;};
void display();
~Book();
private:
string name;
string author;
int sale;
};

void Book::display()
{
cout <<"name:";get_name();cout <<"\n";
cout <<"author:";get_author();cout <<"\n";
cout <<"sales:";get_sale();cout<<"\n";
};

int main()
{
Book book1;
Book book2("math","H_S_Q",70000);

book1.display();
book2.display();

return 0;
}


错误:Linking...
作业3.obj : error LNK2001: unresolved external symbol "public: __thiscall Book::~Book(void)" (??1Book@@QAE@XZ)
Debug/作业3.exe : fatal error LNK1120: 1 unresolved externals
执行 link.exe 时出错.

新手,不用讲得太高深,应该怎么改,谢谢了。
...全文

相关推荐

评论 1
收藏 已收藏
分享
返回顶部
pw2156314
C++ 语言 65,214 成员 250,514 内容