In most other classes I have written, I have no problem in calling a second constructor. But I don't know why the following program that I wrote will always generate error when compiling:
------------------------------------------------------------------------------------
#include <iostream>
#include <stdlib.h>
#include <string.h>
class myDateDiff {
private:
int day;
public:
myDateDiff(void) { day = 0;}
myDateDiff(const int i_day = 0) {
set(i_day);
}
// Destructor defaults
// Copy constructor defaults
// Assignment operator defaults
void set(const int i_day = 0) {
day = i_day;
}
};
int main () {
myDateDiff df3;
return (0);
}
------------------------------------------------------------------------------------
The error message in that:
In function `int main()':
call of overloaded `myDateDiff()' is ambiguous
candidates are: myDateDiff::myDateDiff()
myDateDiff::myDateDiff(int)
Can anyone help? Thanks.