COM SCI 31 Lecture 19: wk10 Lecture 19

41 views3 pages
14 Aug 2017
School

Document Summary

Lecture 19 6/5: (cid:374)a(cid:373)ed lo(cid:272)al varia(cid:271)les (cid:894)(cid:862)auto(cid:373)ati(cid:272) varia(cid:271)les(cid:863)(cid:895) live o(cid:374) (cid:862)the sta(cid:272)k(cid:863, dy(cid:374)a(cid:373)i(cid:272)ally allo(cid:272)ated o(cid:271)je(cid:272)ts live o(cid:374) (cid:862)the heap(cid:863, varia(cid:271)les de(cid:272)lared outside of a(cid:374)y fu(cid:374)(cid:272)tio(cid:374) live i(cid:374) the (cid:862)glo(cid:271)al storage area(cid:863) (cid:894)(cid:862)the stati(cid:272) storage area(cid:863)(cid:895) class pet public: String name() const; //best name given to function. Void removetoy(); private: string m_name; //conventions for naming data members: name_, m_name int m_health; Pet::pet(string nm, int initialhealth) m_name = nm; m_health = initialhealth; m_favoritetoy = nullptr; //a pet can have a toy, but initially doesn"t. Contact the shelter named by the argument, have them. Give you a pet, and initialize the m_name and m_health. To what they tell you string pet::name() const return m_name; void pet::addtoy() delete m_favoritetoy; m_favoritetoy = new toy; void pet::removetoy() delete m_favoritetoy; m_favoritetoy = nullptr; Employee(company* cp, string nm, double sal, int ag); Void receivebonus() const; private: string m_name; double m_salary; int m_age;

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents