0% found this document useful (0 votes)
197 views8 pages

Object Orientation Programming (Oop) Lab

The document describes a class project in object oriented programming to create a bank account class. The bank account class contains data members for the name, account number, type of account, and balance. It also contains member functions like a constructor, deposit, withdraw, and display. The data members are declared as private while the member functions are declared as public. The member functions are defined outside the class. In the main function, a bank object is created and the member functions like deposit, withdraw and display are accessed using the dot operator. The deposit and withdraw functions check the balance before completing the transaction while display prints the name and balance.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
197 views8 pages

Object Orientation Programming (Oop) Lab

The document describes a class project in object oriented programming to create a bank account class. The bank account class contains data members for the name, account number, type of account, and balance. It also contains member functions like a constructor, deposit, withdraw, and display. The data members are declared as private while the member functions are declared as public. The member functions are defined outside the class. In the main function, a bank object is created and the member functions like deposit, withdraw and display are accessed using the dot operator. The deposit and withdraw functions check the balance before completing the transaction while display prints the name and balance.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 8

Object Orientation

Programming
(OOP)LAB
Project 1
Instructor: Atif Bajwa
Group Members:
Hasnain Ahmed (2012216)
Dasnish Ahmed(2012209)
Bilal Atiq (2012237)
Introduction

 Define a class for a bank account that includes the following data members:
 Name of the depositor
 Account Number
 Type of account
 Balance amount in the account
The class also contains the following member functions:
 A constructor to assign initial values
 Deposit function to deposit some amount. It should accept the amount as parameter.
 Withdraw function to withdraw an amount after checking the balance. It
 should accept the amount as parameter.
 Display function to display name and balance.
Data members

In our first lab project of object oriented programming we made a class named as “ bank “ having the following
data members
Private:
 First we initialize the data members as private:
 The class members declared as private can be accessed only by the functions inside the class
 They are not allowed to be accessed directly by any object or function outside the class.
 Only the member functions or the friend functions are allowed to access the private data members of a
class
Member function declaration:
In public we create a construct name bank as same class name
We also declare member function in public and passing amount as a parameter in member function
And declare function inside the class and function definition outside the class

Public:
 All the class members declared under public will be available to everyone
 The data members and member functions declared public can be accessed by other classes too.
 The public members of a class can be accessed from anywhere in the program using the direct member
access operator (.) with the object of that class.
 void data();
 Void deposit(int amount);
 Void withdraw (int amount);
 Void display ();
Member Function Defination

 We declare member function inside the class but definition out side the class we can access it by dot
operator(.)
Main function:

 In main function first we create object of class bank b


 Then access the member function using dot operator(.) and passing amount as a parameter in deposit
function
 Data()
 Deposit amount(a);
 Withdraw ()
 Display()
Result:

 If the user choose the deposit money option then it asks about the money to be deposited.after entering
money it shows total amount after being deposited.
 If the user choose the withdraw money option then it asks about the money to be withdrawn from the
account.first it checks that the withdraw money entered is less than or greater than available money.if it is
greater then it would show error otherwise it would show the remaining money in the account after
withdrawn amount.
 if user choose display function then it will show name of depositor and current balance.

You might also like