Hi,
I have been trying to figure out what is wrong with this code. All I want is an array of structures. But the compiler tells me
functions.cpp:54: error: no matching function for call to `Visits::Visits()'
. I initialized the records, still the same error. I am able to do it in C but as soon as I go to C++ it does not like it. Maybe someone knows why.
Thank you!
public:
Date::Date(int mn, int dy, int yr);
int Date::getDay();
int Date::getMonth();
int Date::getYear();
bool Date::checkDate();
void Date::setDay(int d);
void Date::setMonth(int m);
void Date::setYear(int y);
private:
int month;
int day;
int year;
int checkDay(int);
int checkMonth(int);
int checkYear(int);
};
Your Date class has no default constructor, and since it is a member of your Visits class, Visits is not allowed to have a default constructor either. You should create a default constructor for your Visits class that initializes d correctly, or provide a default constructor for your Date class.
@vlad the code he showed was relevant and I explained the problem.
Also, that statement does not declare a new structure - it works like in C. The error would be something about incomplete types if the structure was not previously defined.
@L B
@vlad the code he showed was relevant and I explained the problem.
Also, that statement does not declare a new structure - it works like in C. The error would be something about incomplete types if the structure was not previously defined
Whan I was writing my post I did not see yet the second his post with the definition of class Date
As for your second statement then for example this declaration declares a new structure