I'm still learing c++ and was following an example from my book. I basically copied their code and added the include and namespace. What am I doing wrong?
Code:
#include <iostream>
#include <string>
using namespace std;
class Date{
int y,m,d;
public:
Date(int y, int m, int d);
int month(){return m;}
int day(){return d;}
int year(){return y;}
};
int main(){
Date b{1970,12,30};
cout<< b.month()<< '\n';
}
Trying to compile with g++ -std=c++11 -o test2 test2.cc
Error:
Date::Date(int, int, int) /var/tmp//ccGuivAs.o
ld: fatal: Symbol referencing errors. No output written to main
collect2: ld returned 1 exit status