Create a C++ class called employee that stores the name (a string) and number (type int) of an employee. From this class derive two classes: manager, which adds a tilte (type string); and scientist, which adds a number of publications (type int). Each of the three classes should have a getdata function (method) to get its data from the user at the keyboard, and a putdata function to display the data. Add a member function of type bool called isOverweight to the manager and scientist classes. Let’s say that an employee with more than 90kg is considered overweight. You can access this function from main() and display the string “Overweight” for overweighted managers and scientists when you display their other data. If manager and scientist objects are to be accessed using pointers to them that are stored in an array of type employee, what do you need to add to the employee base class? Can you instantiate members of this base class? Create a C++ program and instances of manager and scientist classes and call their methods. Then, create pointers of manager and scientist classes and store them in an array of type employee and call the isOverweight method.
السؤال
بسمة امل2
السلام عليكم
ياريت تساعدوني بحل هذا السؤال
Create a C++ class called employee that stores the name (a string) and number (type int) of an employee. From this class derive two classes: manager, which adds a tilte (type string); and scientist, which adds a number of publications (type int). Each of the three classes should have a getdata function (method) to get its data from the user at the keyboard, and a putdata function to display the data. Add a member function of type bool called isOverweight to the manager and scientist classes. Let’s say that an employee with more than 90kg is considered overweight. You can access this function from main() and display the string “Overweight” for overweighted managers and scientists when you display their other data. If manager and scientist objects are to be accessed using pointers to them that are stored in an array of type employee, what do you need to add to the employee base class? Can you instantiate members of this base class? Create a C++ program and instances of manager and scientist classes and call their methods. Then, create pointers of manager and scientist classes and store them in an array of type employee and call the isOverweight method.
تم التعديل في بواسطة عبود سميرتنسيق العنوان
3 أجوبة على هذا السؤال
Recommended Posts
انضم إلى النقاش
يمكنك أن تنشر الآن وتسجل لاحقًا. إذا كان لديك حساب، فسجل الدخول الآن لتنشر باسم حسابك.