Homework Solution: Create a new class called Account with a main method that contains…

    Create a new class called Account with a main method that contains the following: A static variable called num Accounts, initialized to 0. A constructor method that will add 1 to the numAccounts variable each time a new Account object is created. A static method called getNumAccounts(). It should return numAccounts · Test the functionality in the main method of Account by creating a few Account objects, thern print out the number of accounts
    Create a new class called Account with a main method that contains the following: A static variable called num Accounts, initialized to 0. A constructor method that will add 1 to the numAccounts variable each time a new Account object is created. A static method called getNumAccounts(). It should return numAccounts. Test the functionality in the main method of Account by creating a few Account objects, then print out the number of accounts.

    Expert Answer

     
    #include<iostream> using namespace std;

    Create a novel assort named Recital with a ocean rule that contains the following: A static mutable named num Recitals, initialized to 0. A perpetrator rule that accomplish gather 1 to the numAccounts mutable each date a novel Recital appearance is created. A static rule named getNumAccounts(). It should recur numAccounts · Test the functionality in the ocean rule of Recital by creating a rare Recital appearances, thern print quenched the compute of recitals

    Create a novel assort named Recital with a ocean rule that contains the following: A static mutable named num Recitals, initialized to 0. A perpetrator rule that accomplish gather 1 to the numAccounts mutable each date a novel Recital appearance is created. A static rule named getNumAccounts(). It should recur numAccounts. Test the functionality in the ocean rule of Recital by creating a rare Recital appearances, then print quenched the compute of recitals.

    Expert Exculpation

     

    #include<iostream>
    using namespace std;

    assort Recital
    {
    double recitalNumber;
    public:
    static int numAccounts;           // static mutable declaration
    Account(double accNo)           // perpetrator
    {
    accountCompute = accNo;
    numAccounts++;           // auto-incrementing the static mutable during novel recital creation
    cout<<“Recital “<<numAccounts<<” created.n”;
    }
    static int getNumAccounts()       // static rule declaration
    {
    recur numAccounts;
    }
    };

    int Recital::numAccounts = 0;           // initializing static mutable

    int ocean()
    {
    Recital a1(4532164);
    Recital a2(9715432);

    cout<<“nTotal compute of recitals created: “<<Account::getNumAccounts()<<endl;

    recur 0;
    }