Answer to Question #201298 in C++ for Harsh

Question #201298

A sports club needs a program to manage its members. Your task is to define and test a class called 

Member for this purpose.

Define the Member class using 

Private data members: 

Member Number, Name, Birthday. 

Public Methods:

Constructor with one parameter for each data member

Access methods for each data member.

The birthday is read-only.

A method for formatted screen output of all data members.

Implement the necessary methods.

Test the new Member class by creating at least two objects with the data of your choice and calling the 

methods you defined. 

Add a static member called ptrBoss to the class. If no chairperson has been appointed, the pointer should 

point to NULL.

Additionally, define the static access methods getBoss() and setBoss(). Use a pointer to 

set and return the object in question.

Test the Member class by reading the number of an existing member, making the 

member the new chairperson and displaying the chairperson using getBoss(). 


1
Expert's answer
2021-05-31T16:36:41-0400


#include <iostream>


using namespace std;


class Members{
    
    private:
        string MemberNumber, Name, Birthday;
        
    public:
        static int ptrBoss;
        static int * getBoss(){
            return &ptrBoss;
        }
        static void * setBoss(int p){
            ptrBoss=p;
        }
        Members(string m,string n,string b){
            MemberNumber = m;
            Name=n;
            Birthday=b;
            ptrBoss++;
        }
        string getMemberNumber(){
            return MemberNumber;
        }
        string getName(){
            return Name;
        }
        string getBirthday(){
            return Birthday;
        }


};
int Members::ptrBoss= 0;
int main()
{
    Members m1("1234","John","8/3/2000");
    Members m2("1234","James","8/3/2001");
    Members m3("1234","Mary","8/3/2002");
    m1.getMemberNumber();
    m1.getName();
    m1.getBirthday();
    m2.getMemberNumber();
    m2.getName();
    m2.getBirthday();
    m3.getMemberNumber();
    m3.getName();
    m3.getBirthday();
    Members::getBoss();
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog