workshop_3.cpp

Info icon This preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
#include <iostream> #include <string> class Rapper { protected: std::string name; int money; int hoes; std::string song_name; public: Rapper() {}; Rapper(int, int); int get_money() {return money;} int get_hoes() {return hoes;} Rapper operator+ (const Rapper&); virtual std::string get_song(){return song_name;} }; Rapper::Rapper (int m, int h) { money = m; hoes = h; } Rapper Rapper::operator+ (const Rapper& param) { Rapper temp; temp.money = money + param.money; temp.hoes = hoes + param.hoes; return temp; } class Eminem: public Rapper { public: Eminem(); Eminem(int, int); std::string get_song(){return song_name;} }; Eminem::Eminem (int m, int h) { name = "Eminem"; song_name = "Real Slim Shady"; money = m; hoes = h; } int main() { // --- Part 1 ---- Rapper rapper0(2000, 18); std::cout << "Rapper 0 has "<< rapper0.get_money()<<" dollars.\n"; std::cout << "AND "<< rapper0.get_hoes()<<" hoes.\n"; Rapper rapper1(2000, 18); Rapper rapper2(2000, 19);
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern