I am working on a date wrapper class in c++
I want to copy the tm structure to another structure, but it throws unresolved external link
Error 2 error LNK2001: unresolved external symbol "public: static struct tm * DateUtils::generateDateTimeStruct" (?generateDateTimeStruct@DateUtils@@2PAUtm@@A)
class DateUtils
{
public:
DateUtils()
{
}
static int getTodaysDate();
static tm * myDateTime;
static void generateDateTimeStruct();
};
tm* DateUtils::myDateTime = NULL;
int DateUtils::getTodaysDate()
{
// If i comment the calling, it does not throws an error
generateDateTimeStruct();
return DateUtils::myDateTime->tm_hour;
}
static void generateDateTimeStruct(){
time_t now = time(0);
static tm s;
now = time(NULL);
localtime_s(&s, &now);
DateUtils::myDateTime = &s;
}