Link Errors - Please help me out
I was using factory pattern in my codes. But I got link errors when I
built my project, could anybody help me out please???? I have struggled
for this problem for one day :(
Any help would be greatly appreciated!
Errors Information:
error LNK2019: unresolved external symbol "protected: __thiscall
Event::Event(class std::basic_string<char,struct
std::char_traits<char>,class std::allocator<char> >,class
std::basic_string<char,struct std::char_traits<char>,class
std::allocator<char> >,class Date,class Date)"
(??0Event@@IAE@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@0VDate@@1@Z)
referenced in function "private: __thiscall
ConcreteEvent::ConcreteEvent(class std::basic_string<char,struct
std::char_traits<char>,class std::allocator<char> >,class
std::basic_string<char,struct std::char_traits<char>,class
std::allocator<char> >,class Date,class Date)"
(??0ConcreteEvent@@AAE@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@0VDate@@1@Z)
My codes:
/*.h file/
class Event {
public:
std::string description; // Description of Event
std::string location; // Place where event is taking place
const Date start; // Date and time when the event starts (inclusive)
const Date end; // Date and time when the event ends (exclusive)
static Event & make(Date,Date);
private:
static Event *_Ev;
protected:
// Event Constructor: newly created Event
static Event *_Event;
Event(std::string , std::string , Date , Date);
// Destructor
~Event();
};
class ConcreteEvent:public Event{
friend class Event;
private:
static ConcreteEvent *_concreteEvent;
ConcreteEvent(std::string , std::string , Date, Date);
~ConcreteEvent();
public:
static ConcreteEvent * getInstance(std::string loc, std::string desc,
Date s, Date e) ;
};
/* .cpp file */
Event * Event::_Ev=NULL;
Event & Event::make(Date start,Date end)
{
Event *e=0;
if ((start<end) || (start==end))
{
e=ConcreteEvent::getInstance("","",start,end);
}
else
{
throw "The start date of an event cannot be later than the end
date!";
}
return *e;
}
ConcreteEvent::ConcreteEvent(std::string loc, std::string desc, Date s,
Date e):Event(loc,desc,s,e)
{}
ConcreteEvent::ConcreteEvent(Calendar c,Date s, Date e):Event(c,s,e)
{}
ConcreteEvent * ConcreteEvent::_concreteEvent=NULL;
ConcreteEvent * ConcreteEvent::getInstance(std::string loc, std::string
desc, Date start, Date end)
{
if (_concreteEvent==0)
{
_concreteEvent=new ConcreteEvent(loc,desc,start,end);
}
return _concreteEvent;
}