Program To Demonstrate An Array Of Bank Account Objects Using C++

LEVEL: Beginner

Whats in this post?

  1. Code
  2. Output
  3. Background and Explanation of the code

Code


To copy code: Click View Source “View Source” on the right of this code snippet.


Background and Explanation of the code


In the above program , the statement account acc [10]; creates an array of 10 objects of the account class.The for loops are used to invoke member functions input_data ( ) and display_data ( ) for a particular element of an array of objects.The statement acc [i].input_data ( ); invokes the member function input_data ( ) for ith object of acc array.

OUTPUT

Enter number of account holders = 2

Enter account number, name, balance = 101 ankur 2000

Enter account number, name, balance = 102 binay 5000

Information of account = 1

Account number = 101

Account holder name = ankur

Account balance = 2000

Information of account =  2

Account number =  102

Account holder name =  binay

Account balance =  5000