// z2.4-Restaurant-inline.cc // #include #include using namespace std; class Restaurant { // Info about a restaurant public: // SetName() and SetRating() are implicitly inline, defined here: void SetName(string restaurantName) { // Sets the restaurant's name name = restaurantName; } void SetRating(int userRating) { // Sets the rating (1-5, with 5 best) rating = userRating; } // Print() is inline, defined further below void Print(); // Prints name and rating on one line private: string name; int rating; }; // Prints name and rating on one line inline void Restaurant::Print() { cout << name << " -- " << rating << endl; } int main() { Restaurant favLunchPlace; Restaurant favDinnerPlace; favLunchPlace.SetName("Central Deli"); favLunchPlace.SetRating(4); favDinnerPlace.SetName("Friends Cafe"); favDinnerPlace.SetRating(5); cout << "My favorite restaurants: " << endl; favLunchPlace.Print(); favDinnerPlace.Print(); return 0; }