Help: Error LNK2019

Hi. I'm new to C++ and I receive error LNK2019. I don't know whats the problem is (I decided to test my code halfway through the coding process).

#include <string>
#include <iomanip>
using namespace std;

class BOOK
{
public:
	BOOK ( string );
	void setbook ( string );
	string getbooktype();
	void welcomemessage();
	void inputbook();
	void checkout();
private:
	string book;
	int totalbook1;
	int totalbook2;
	int totalbook3;
	int totalbook4;
	int totalbook5;
	double pricebook1;
	double pricebook2;
	double pricebook3;
	double pricebook4;
	double pricebook5;
};

This is my header file

// BOOKAZINE.cpp

#include <iostream>
#include <iomanip>
#include "switch.h"
using namespace std;

BOOK::BOOK ( string name )
{
	setbook( name );
	totalbook1 = 0;
	totalbook2 = 0;
	totalbook3 = 0;
	totalbook4 = 0;
	totalbook5 = 0;
	pricebook1 = 0;
	pricebook2 = 0;
	pricebook3 = 0;
	pricebook4 = 0;
	pricebook5 = 0;
}

void BOOK::welcomemessage()
{
	cout << "Welcome to BOOKAZINE WEB";
	cout << "Books Available in the BOOKAZINE WEB";
	cout << setw(3) << "\n 1 (Ladybird - $15.98)";
	cout << setw(3) << "\n 2 (Sidney Sheldon - $25.50)";
	cout << setw(3) << "\n 3 (Nora Roberts - $28.45)";
	cout << setw(3) << "\n 4 (Penguin Classics - $40.55)";
	cout << setw(3) << "\n 5 (Virginia Andrews - $42.98)";
}

void BOOK::inputbook()
{
	int choice;
	double totalprice;
	
	totalprice = pricebook1 + pricebook2 + pricebook3 + pricebook4 + pricebook5;

	cout << "Input a value based on the book type (-1 to quit)";
	cin >> choice;
	
	int counter;

	switch (choice)
	{
		case '1':
			++counter;
			++totalbook1;
			pricebook1 += 15.98;
			break;
		case '2':
			++counter;
			++totalbook2;
			pricebook2 += 25.50;
			break;
		case '3':
			++counter;
			++totalbook3;
			pricebook3 += 28.45;
			break;
		case '4' :
			++counter;
			++totalbook4;
			pricebook4 += 40.55;
			break;
		case '5' :
			++counter;
			++totalbook5;
			pricebook5 += 42.98;
			break;
		case '-1' :
			cout << "CHECKOUT";
			cout << "Ladybird             :" << setw(3) << "X" << totalbook1 << setw(3) << pricebook1;
			cout << "Sidney Sheldon       :" << setw(3) << "X" << totalbook2 << setw(3) << pricebook2;
			cout << "Nora Roberts         :" << setw(3) << "X" << totalbook3 << setw(3) << pricebook3;
			cout << "Penguin Classics     :" << setw(3) << "X" << totalbook4 << setw(3) << pricebook4;
			cout << "Virginia Andrews     :" << setw(3) << "X" << totalbook5 << setw(3) << pricebook5;
			cout << "\n______________________________________\n";
			cout << "Total Book Purchased : " << setw(3) << counter;
			cout << "Total Book Cost      : " << setw(3) << totalprice;
		default:
			cout << "You have inputted an invalid value!";
			cout << "Please enter a valid value";
			break;
	}
}


This is my cpp file for string statement.


Anybod1>------ Build started: Project: BOOKAZINEWEB, Configuration: Debug Win32 ------
1>BOOKAZINEWEB.obj : error LNK2019: unresolved external symbol "public: void __thiscall BOOK::setbook(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?setbook@BOOK@@QAEXV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function "public: __thiscall BOOK::BOOK(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (??0BOOK@@QAE@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
1>MSVCRTD.lib(crtexe.obj) : error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup
1>C:\Users\SONY\Documents\Visual Studio 2010\Projects\BOOKAZINEWEB\Debug\BOOKAZINEWEB.exe : fatal error LNK1120: 2 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

My error.


What is the problem?
What is the problem?


You didn't define the BOOK::setbook function.
How to fix this problem? I don't really understand what to edit.
closed account (SGb4jE8b)
Write a definition for the member function BOOK:setBook(). I mean what the rules of the function are and how they are going to manipulate the string parameter passed to the function.
Sorry but I still don't really understand. Can you explain in details.
You've written a class called BOOK.

You've defined some methods in the BOOK class - BOOK::welcomemessage() and BOOK::inputbook().

You've also defined a constructor for the BOOK class - BOOK:BOOK().

In the first line of that constructor, you are calling a method called setbook(). But you haven't written a function called setbook().

You need to write that function.
Topic archived. No new replies allowed.