classes in headers

Hi,

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?

thanks

main.cpp:
#include <iostream>
#include "VDate.h"
using namespace std;
int main()
{
VDate birthday;
birthday.SetDate(6, 11, 1987);
cout << birthday.GetDay() << "/" << birthday.GetMonth() << "/" << birthday.GetYear() << endl;
return 0;
}

VDate.h:
#ifndef VDATE_H
#define VDATE_H

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
It looks like the object file of VDate.cpp was not included in the project.
thanks, well spotted.
Topic archived. No new replies allowed.