Represent bank account - C++ Program

Q. Define a class to represent a bank account. Include the following members:

Data members:
1) Name of the depositor
2) Account number
3) Type of account
4) Balance amount in the account.

Member functions:
1) To assign initial values
2) To deposit an amount
3) To withdraw an amount after checking the balance
4) To display name and balance.

Write a main program to test the program.



using namespace std;

class bank
        int acno;
        char nm[100], acctype[100];
        float bal;  
        bank(int acc_no, char *name, char *acc_type, float balance)  //Parameterized Constructor
                strcpy(nm, name);
                strcpy(acctype, acc_type);
        void deposit();
        void withdraw();
        void display();
void bank::deposit()   //depositing an amount
        int damt1;
        cout<<"\n Enter Deposit Amount = ";
void bank::withdraw()  //withdrawing an amount
        int wamt1;
        cout<<"\n Enter Withdraw Amount = ";
                cout<<"\n Cannot Withdraw Amount";
void bank::display()  //displaying the details
        cout<<"\n ----------------------";
        cout<<"\n Accout No. : "<<acno;
        cout<<"\n Name : "<<nm;
        cout<<"\n Account Type : "<<acctype;
        cout<<"\n Balance : "<<bal;  
int main()
        int acc_no;
        char name[100], acc_type[100];
        float balance;
        cout<<"\n Enter Details: \n";
        cout<<"\n Accout No. ";
        cout<<"\n Name : ";
        cout<<"\n Account Type : ";
        cout<<"\n Balance : ";
        bank b1(acc_no, name, acc_type, balance);  //object is created
        b1.deposit(); //
        b1.withdraw(); // calling member functions
        b1.display(); //
        return 0;


bank details