Declare a Class

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • akimat
    New Member
    • Nov 2006
    • 1

    Declare a Class

    Declare a class named Account, which has a private data member, a constructor, and three public function members. The data member is named balance and store the balance money in the account. The constructor has a default value as zero. The three public function members are ShowBalance function which will be return balance to the caller, WIthdraw function which will return the amount to be withdrew and update the balance if it can be withdrew(that is all accounts need to keep balance more or equal to zero), otherwise return 0, and Deposit function which will increase the value of balance.


    i need to know how many function members beside constructor are there and name them
  • dariophoenix
    New Member
    • Oct 2006
    • 34

    #2
    Code:
    class Account{
       float balance;
    public:
       Account(float balance=0);
       float balance();
       float withdraw(float withdrawal);
       void deposit(float depositedAmount);
    };
    Last edited by dariophoenix; Nov 9 '06, 02:42 AM. Reason: Error

    Comment

    • sicarie
      Recognized Expert Specialist
      • Nov 2006
      • 4677

      #3
      Originally posted by akimat
      Declare a class named Account, which has a private data member, a constructor, and three public function members. The data member is named balance and store the balance money in the account. The constructor has a default value as zero. The three public function members are ShowBalance function which will be return balance to the caller, WIthdraw function which will return the amount to be withdrew and update the balance if it can be withdrew(that is all accounts need to keep balance more or equal to zero), otherwise return 0, and Deposit function which will increase the value of balance.


      i need to know how many function members beside constructor are there and name them
      Right....um, doesn't the total of described members in the first sentence answer your question? It looks like there are five, and they even go on to name them... I'm sorry, I don't think I'm understanding your question.

      Comment

      • dariophoenix
        New Member
        • Oct 2006
        • 34

        #4
        Forgot the destructor

        Comment

        Working...