No suitable default constructor available Error appears
This is one of the header files of the fruit-buying program
There's only one constructor error stuck here.
class FruitSeller
{
private:
const int APPLE_PRICE;
const int ORANGE_PRICE;
int numOfApples;
int numOfOranges;
int myMoney;
public:
FruitSeller(int aprice, int oprice, int anum, int onum, int money)
: : APPLE_PRICE(aprice), ORANGE_PRICE(oprice), numOfApples(anum), numOfOranges(onum), myMoney(money)
{
}
void InitMembers(int aprice, int oprice, int anum, int onum, int money);
int SaleApples(int money);
int SaleOranges(int money);
void ShowSalesResult();
};
Please add the default constructor under public as below.
FruitSeller() : APPLE_PRICE(0), ORANGE_PRICE(0), numOfApples(0), numOfOranges(0), myMoney(0)
{
}
© 2024 OneMinuteCode. All rights reserved.