I just started learning classes in C++ and I get this error for the code below: conflicting declaration 'std::string PizzaOrder::toppings_offered'
Can someone explain what’s wrong with my code here?
class PizzaOrder
{
public:
//all the toppings that are offered, constant array of strings
static string toppings_offered[5];
static double topping_base_cost;
};
string PizzaOrder::toppings_offered = {"onions", "bell peppers", "olives", "spinach", "tomatoes"};
double PizzaOrder::topping_base_cost = 0.50;
You forgot that
toppings_offeredis an array of strings, rather than a string:(BTW, I’d expect a pizza order to order toppings, not offer them. Could it be that your design still is a bit scrambled?)