![]() |
| ||
| Constructor overloading question Hello, I need to provide 2 overloaded constructors, each one displaying a date in a different format. Below is my class implementations, header file and main() function code snippets. The code is followed by the compilation error I get. I have tried a number of things, mainly changing the order of my constructors and such, but I keep getting this error. Could I get some expert guidance please? There is a lot of code here; some could have been abridged more, but I color-coded the code in question for easy readability (HOPEFULLY easy for you) THANKS!!! // Date.cpp // Date class member-function definitions. #include <iostream> // Date.h // Date class definition; Member functions defined in Date.cpp // Fig. 10.14: fig10_14.cpp1>cprogram files\c++examples\cpphtp6e_examples\ch10\fig10_10_ 14\fig10_14.cpp(19) : error C2664: 'Date:ate(int,int,int)' : cannot convert parameter 1 from 'const char [5]' to 'int' 1> There is no context in which this conversion is possible 1>cprogram files\c++examples\cpphtp6e_examples\ch10\fig10_10_ 14\fig10_14.cpp(26) : error C2664: 'Date:ate(int,int,int)' : cannot convert parameter 1 from 'const char [9]' to 'int' 1> There is no context in which this conversion is possible |
| ||
| Re: Constructor overloading question date.cpp: >>Date:Date That should have two :, not one Date::Date |
| ||
| Re: Constructor overloading question Quote:
Sorry for not following the rules carefully when I posted this. I noticed you had to clean it up quite a bit - thanks! |
| ||
| Re: Constructor overloading question using VC++ 2008 Express, I don't get that error after correcting the 2 :: s The code you posted contains a lot of other errors too. There are several lines with only one :, and Date::print() is named Date::print2() in the header file. Here's the errors I get now d:\dvlp\test2\test2\test2.cpp(30) : error C3861: 'print': identifier not found |
| ||
| Re: Constructor overloading question After correcting a bunch of errors I'm back to your original question. The problem is that there is no constructor with the first paramter as const char*, only const char, which of course is not the same thing. |
| ||
| Re: Constructor overloading question Quote:
|
| ||
| Re: Constructor overloading question Depends on how you want to use it. See this |
| All times are GMT -4. The time now is 5:37 am. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC