I am trying to include a small test class in a header file and call it from a main program, but when compiling it gives some errors. could you help me out?
class VDate
{
private:
int m_nMonth;
int m_nDay;
int m_nYear;
public:
VDate() { } // private default constructor
VDate(int nMonth, int nDay, int nYear);
void SetDate(int nMonth, int nDay, int nYear);
int GetMonth() { return m_nMonth; }
int GetDay() { return m_nDay; }
int GetYear() { return m_nYear; }
};
#endif
VDate.cpp:
#include "VDate.h"
// VDate constructor
VDate::VDate(int nMonth, int nDay, int nYear)
{
SetDate(nMonth, nDay, nYear);
}
// Date member function
void VDate::SetDate(int nMonth, int nDay, int nYear)
{
m_nMonth = nMonth;
m_nDay = nDay;
m_nYear = nYear;
}
When compiling, this error shows up:
Undefined symbols:
"VDate::SetDate(int, int, int)", referenced from:
_main in cc9116sO.o
ld: symbol(s) not found
collect2: ld returned 1 exit status