No appropriate default constructor!!

hi ^___^

i have an error in my prog that says that no appropriate default constructor
is avaliable and the thing that there is i dont know why this is happin

here are my constructor if anyone can help me.
in the heder of extDateType:
 
extDateType(std::string,int,int ,int); 

and in the implimentation:
1
2
3
4
extDateType::extDateType(string M="January",int DAY, int MONTH, int YEAR):dateType(DAY,MONTH,YEAR)
{
	Month=M;
	;}

and for dateType in the heder:
 
dateType(int Day=1,int Month=1, int Year=1500);

and the in implemntation file:
1
2
3
 dateType::dateType(int Day,int Month ,int Year)
{
 day=Day;month=Month;year=Year;}

and in the client i declared the opject like this:
 
 extDateType Date;


there shouldent be a problem right..?
Your exDateType constructor looks incorrect; you have a default parameter for the first parameter, but none of the following. And in any case you need to pass parameters to your constructor if you don't have default options for all of them. As you have it, you aren't passing any.
A default constructor is a constructor that takes no parameters (or rather, one that can be called without specifying any parameters).

Since you do not have a constructor that can be called with no parameters, you cannot create default constructed objects. That is why this line: extDateType Date; is giving you an error.

Solutions are:

1) Make a new constructor that takes no parameters (ex: extDateType();)

or

2) Give default values to all of the parameters to your existing constructor (ex: extDateType(string M="January",int DAY=1, int MONTH=1, int YEAR=1900)) and be sure to put the default parameters in the header. Putting them in the implementation is useless.



Also.... you can't have a default value for just the first parameter. Once you give a default value for a param, you must have default values for every param that follows otherwise the default can never be used. Either:

1) Get rid of M's default value
or
2) Move M so that it's the last parameter given to the ctor
or
3) Give default values for all parameters following M
thanks alot ,i want to corrcet smth in my understanding ..
now what i thought is if i initialize the M only and the class dateType
will initialzes the other would be fine other than iniliazing all of them
in the derived class !!

other than that thanks verey much..=>
Topic archived. No new replies allowed.