I am writing a time class. I have set the default constructor using member initialization list to set the values
// Time .h
Time(int hour = 0, int minute = 0, int second = 0);
// Time.cpp
Time::Time(int hour, int minute, int second)
: hour(hour), minute(minute), second(second)
{
cout << "Constructor Time (default ) "
<< (hour < 12 ? "0" : "") << hour << ":"
<< (minute < 10 ? "0" : "") << minute << ":"
<< (second < 10 ? "0" : "") << second << endl;
}
The default consttructor works. Now, I have to make a constructor with three arguments, representing the time components, hour, minute, second.
I did it this way....
//Time.h
Time(int hour, int minute, int second);
//Time.cpp
Time::Time(int hour, int minute, int second)
{
cout << "Testing the 3 argument constructor" << endl;
}
When i compile i get this error
error C2535: '__thiscall Time::Time(int,int,int)' : member function already defined or declared
Anybody have any ideas???