I can't figure out why the following code fails to compile under gcc, but works fine when plugged using Microsoft's compiler (using VS2010).
Under GCC, when it gets to the time5 line, the compile fails with the following error:Code:TimeCalc time1; TimeCalc time2("16:28"); TimeCalc time3("00:16"); TimeCalc time4 = time3; TimeCalc time5 = "14:34";
The functions it's suggesting are:Code:... Lab0.cpp||In function 'int main()':| ... Lab0.cpp|250|error: no matching function for call to 'TimeCalc::TimeCalc(TimeCalc)'| ... Lab0.cpp|201|note: candidates are: TimeCalc::TimeCalc(TimeCalc&)| ... Lab0.cpp|186|note: TimeCalc::TimeCalc(const char*)| ... Lab0.cpp|112|note: TimeCalc::TimeCalc()| ||=== Build finished: 1 errors, 0 warnings (0 minutes, 0 seconds) ===|
line 112: the default constructor
line 186: the constructor taking a string as input
line 201: the copy constructor
The program compiles and runs fine under VS2010. When I use the debugger and step through the program, when it gets to time5, it uses the same constructor time2 and time3 use ( TimeCalc(const char* timeIn) ). I don't see why it would be failing under GCC, because it seems like a simple enough statement. I thought time2/time3 and time5 were equivalent ways to construct something?
Which compiler is wrong or right? Both compilers are running the stock installs, no extra messing around in the options. Is one or the other incomplete? Deviating? I don't have a preference right now of one over the other, I just want to know what the real error is, and what the proper way to handle it is.