I am learning C++ and have a simple Date class where I am trying to set a value for the Date.
Here are the source code files –
Date.h
class Date{
private:
int month;
int day;
int year;
public:
Date();
void setDate(int m, int d, int y);
};
and Date.cpp
#include "Date.h"
Date::Date()
{
month = 1;
day = 1;
year = 80;
};
void Date :: setDate(int m1, int d1, int y1){
month = m1;
day = d1;
year = y1;
};
However, when I compile the code, I get the error message –
Undefined symbols for architecture x86_64:
"_main", referenced from:
start in crt1.10.6.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
Can someone please help ?
Thanks
You’re missing a main function. Add this to either a new file (like main.cpp, and include it when compiling and linking) or to your other .cpp file.
And put your code to run the program in the braces.