I have an abstract class called LibItem, and a DVD class that is derived from this class.
Here is my code:
DVD.h:
//---------------------------------------------------------------------------
#ifndef DVDH
#define DVDH
class DVD : public LibItem
{
public:
DVD(const std::string&, const std::string&, const std::string&, const std::string&, const std::string&, const std::string&, int, const std::string&, const std::string&, const std::string&);
void setRunningTime(int RunningTimeDetails);
int getRunningTime();
void setDirector(const std::string&);
std::string getDirector();
void setStudio(const std::string&);
std::string getStudio();
void setProducer(const std::string&);
std::string getProducer();
void PrintDetails();
private:
DVD();
int RunningTime;
std::string Director;
std::string Studio;
std::string Producer;
};
//---------------------------------------------------------------------------
#endif
DVD.cpp:
//---------------------------------------------------------------------------
#pragma hdrstop
#include "DVD.h"
DVD::DVD(const std::string& setItemTitle, const std::string& setItemAuthor, const std::string& setItemReleaseDate, const std::string& setItemCopyright, const std::string& setItemGenre, const std::string& setItemStatus, int setItemRunningTime, const std::string& setItemDirector, const std::string& setItemStudio, const std::string& setItemProducer)
{
setDetails(setItemTitle, setItemAuthor, setItemReleaseDate, setItemCopyright, setItemGenre, setItemStatus);
setRunningTime(setItemRunningTime);
setDirector(setItemDirector);
setStudio(setItemStudio);
setProducer(setItemProducer);
}
void DVD::setRunningTime(int RunningTimeDetails)
{
RunningTime = RunningTimeDetails;
}
int DVD::getRunningTime()
{
return RunningTime;
}
void DVD::setDirector(const std::string& DirectorDetails)
{
Director = DirectorDetails;
}
std::string DVD::getDirector()
{
return Director;
}
void DVD::setStudio(const std::string& StudioDetails)
{
Studio = StudioDetails;
}
std::string DVD::getStudio()
{
return Studio;
}
void DVD::setProducer(const std::string& ProducerDetails)
{
Producer = ProducerDetails;
}
std::string DVD::getProducer()
{
return Producer;
}
void DVD::PrintDetails()
{
cout << "Title: " << getTitle() << endl;
cout << "Author: " << getAuthor() << endl;
cout << "Release Date: " << getReleaseDate() << endl;
cout << "Copyrite: " << getCopyright() << endl;
cout << "Genre: " << getGenre() << endl;
cout << "Status: " << getStatus() << endl;
cout << "Running Time: " << getRunningTime() << endl;
cout << "Director: " << getDirector() << endl;
cout << "Studio: " << getStudio() << endl;
cout << "Producer: " << getProducer() << endl;
}
//---------------------------------------------------------------------------
#pragma package(smart_init)
I am getting this error:
[ILINK32 Error] Error: Unresolved external ‘DVD::DVD(std::basic_string, std::allocator >&, std::basic_string, std::allocator >&, std::basic_string, std::allocator >&, std::basic_string, std::allocator >&, std::basic_string, std::allocator >&, std::basic_string, std::allocator >&, int, std::basic_string, std::allocator >&, std::basic_string, std::allocator >&, std::basic_string, std::allocator >&)’ referenced from H:\2012\TRIMESTER 2\IT6253 – C++ PROGRAMMING\ASSESMENT\QUESTION 5\WIN32\DEBUG\QUESTION 5.OBJ
Can I please have some help in fixing this error?
You are missing DVD.o from your linking.
If you post the way you link your program or your Makefile file I will tell you where and how to add it.
In general, let’s say your program consists of main.cpp file, and it includes your DVD.h, as well as other headers. Let’s also assume that you compile (and link) it using command:
In order to be able to have the DVD body available in your program you need to do:
Of course your Makefile, if you use it, may differ, and you may see something like this in the place where you link your myprogram code:
g++ main.o -o myprogram. In this case you need to find where you build main.o, and do the same for DVD.o.I hope it will help.