0

Can anyone help me to find out why I get these linkage errors:

Error   1   error LNK2019: unresolved external symbol "private: __thiscall Month::Month(int)" (??0Month@@AAE@H@Z) referenced in function "public: static class Month __cdecl Month::Jan(void)" (?Jan@Month@@SA?AV1@XZ)  c:\Users\vigen\documents\visual studio 2012\Projects\Item18TestingInterface\Item18TestingInterface\Source.obj   Item18TestingInterface

Error   2   error LNK1120: 1 unresolved externals   c:\users\vigen\documents\visual studio 2012\Projects\Item18TestingInterface\Debug\Item18TestingInterface.exe    1   1   Item18TestingInterface

when I run the following code

#include <iostream>
using namespace std;

struct Day {
    explicit Day(int d): val(d) {}
    int val;
};

struct Year {
    explicit Year(int y): val(y){};
    int val;
};


class Month {
    public:
        static Month Jan(){return Month(1);}
        static Month Feb(){return Month(2);}
        static Month Mar(){return Month(3);}
        static Month Apr(){return Month(4);}

        static Month May(){return Month(5);}
        static Month Jun(){return Month(6);}
        static Month Jul(){return Month(7);}
        static Month Aug(){return Month(8);}

        static Month Sep(){return Month(9);}
        static Month Oct(){return Month(10);}
        static Month Nov(){return Month(11);}
        static Month Dec(){return Month(12);}

    private:
        explicit Month(int m);
};

class Date {
    public:
        Date(Month& m, const Day& d, const Year& y){};
};

int main () {
    Date date(Month::Jan(), Day(30), Year(1995)); 
}
C1pher
  • 1,933
  • 6
  • 33
  • 52
Vigen
  • 1
  • 2
  • [See this question.](http://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix) – chris Dec 13 '13 at 22:11

1 Answers1

0

explicit Month(int m); has no definition. Changing it to explicit Month(int m){} should work.

David
  • 27,652
  • 18
  • 89
  • 138