我正在學習C++,並且有一個簡單的Date類,我試圖爲Date設置一個值。C++錯誤 - 架構x86_64的未定義符號:
這裏是源代碼文件 -
Date.h
class Date{
private:
int month;
int day;
int year;
public:
Date();
void setDate(int m, int d, int y);
};
和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;
};
然而,當我編譯代碼,我得到錯誤信息 -
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
有人可以幫忙嗎?
謝謝