Question: C++ Mutators, accessors, and private helpers. Define the Eatery class's SetName() mutator that sets data member name to eateryName, followed by 's Deli, and the
C++
Mutators, accessors, and private helpers.
Define the Eatery class's SetName() mutator that sets data member name to eateryName, followed by "'s Deli", and the SetCity() mutator that sets data member city to eateryCity.
Ex: If the input is:
Mel Hartford
then the output is:
Eatery: Mel's Deli City: Hartford
#include
class Eatery { public: void SetName(string eateryName); void SetCity(string eateryCity); void Print() const; private: string name; string city; };
/* Your code goes here */
void Eatery::Print() const { cout << "Eatery: " << name << endl; cout << "City: " << city << endl; }
int main() { Eatery restaurant; string inputName; string inputCity;
cin >> inputName; cin >> inputCity; restaurant.SetName(inputName); restaurant.SetCity(inputCity);
restaurant.Print();
return 0; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
