hi plz try to solve
method of deduct fees that chrges$2.5(using withdraw method)for the forth transaction and resets the number to zero
how to resets the transactioncount zero in child class checkaccount

#include <iostream.h>
#include <conio.h>
#include <string>


class bankaccounts
{
  protected:
  double balance;


  public:

  bankaccounts()
  {balance=0.0;}

  bankaccounts(double b)
  {balance=b;}

  void deposit(double dep)
  {
  if(dep>0)
    balance+=dep;
  }

  void withdraw(double wd)
  {
  if(wd>0 && wd<=balance)

  balance-=wd;
  }

  double getbalance()
  {
    return balance;
  }

  void transfer(double amt , bankaccounts db , bankaccounts cr)
  {
  if(amt>0 && amt <= db.getbalance())
 {
  db.withdraw(amt);
  cr.deposit(amt);
  cout<<"your balance is : "<<db.getbalance()<<endl;

  cout<<"another balance is: "<<cr.getbalance()<<endl;


  }
   else
    {
    cout<<"amount is less then Balance"<<endl;
    }
  }

};




class checkaccount : public bankaccounts
{
   protected:
   int transactioncount;

   public:
   checkaccount()
   {transactioncount=0;}

   checkaccount(int b)
   {transactioncount=b;}

   void deductfees()
   {
     if(trasactioncount==4)
     {

     }
   }

};
 /*
class savingaccount : public bankaccounts
{
   protected:

   double interestrate;

   public:
    savingaccount()
    {}

    void addinterest()
    {}

};
*/

void main()
{








 getch();

}

how to resets the transactioncount zero in child class checkaccount

How about a public Reset() member function that does it?

void checkaccount::Reset()
{
    transactioncount = 0;
}

Resetting that count seems off to me, since presumably it's internal data that the caller shouldn't have access to, but I'm not familiar with your requirements.

This article has been dead for over six months. Start a new discussion instead.