I am getting the error "Does not contain a constructor that takes 0 arguments" from my c# code below:
public class Holiday
{
string startDate, endDate, firstName, lastName, emailAddress, numberOfGuests;
private double Cost = 100;
public Holiday(string start, string end, string first, string last, string email, string guestCount)
{
startDate = start;
endDate = end;
firstName = first;
lastName = last;
emailAddress = email;
numberOfGuests = guestCount;
}
public double test
{
get { return Cost; }
}
}
public class AdventureHoliday : Holiday
{
public AdventureHoliday(string start, string end, string first, string last, string email, string guestCount)
: base(start, end, first, last, email, guestCount)
{
}
public double totalcost()
{
double adventureAdditional = 0.50;
double xcost = test + (test * adventureAdditional);
return xcost;
}
}
public class CulturalHoliday : Holiday
{
public CulturalHoliday(string start, string end, string first, string last, string email, string guestCount)
: base(start, end, first, last, email, guestCount)
{
}
public double totalcost()
{
double culturalAdditional = 1.0;
double xcost = test + (test * culturalAdditional);
return xcost;
}
I have looked at the various threads for this problem and they all seem to indicate that the problem should be solved by adding:
: base(start, end, first, last, email, guestCount)
I have added this to the second class and am still getting the error. I am getting this for both the Adventure Holiday and Cultural Holiday on lines 201 and 125
(public class AdventureHoliday : Holiday)
and
public class CulturalHoliday : Holiday
Does anyone have any ideas? Sorry if I have missed something stupid. Thanks in advance
See Question&Answers more detail:
os