In this problem i have to develop a program to make a class account with derived class as current account(cur_acct).I have to store the customer name,a/c number and a/c type in the class account and the other details in current account class.
My query is that my program is not taking the account number and account type as the input from user.
#include<iostream>
using namespace std;
class account
{
int bal;
char customer_name[20],type[20],account_number[20];
public:
void display1()
{
bal=10000;
cout<<"customer name:";
cin>>customer_name[20];
}
void display2()
{
cout<<"\naccount number :";
cin>>account_number[20];
}
void display3()
{
cout<<"\ntype of account";
cin>>type[20];
}
int get_bal()
{
return bal;
}
};
class cur_acct: public account
{
int d,e,f;
public:
void display()
{
cout<<"\ncheque book available.\n";
}
int input_deposit(int x)
{
d=x;
cout<<"deposited amount is:"<<d;
e=get_bal()+d;
Lines 13,18,23: Your cin's are defective. You're trying to input a single character into the 21st character of the array. This is an out of bounds reference. Your arrays contain 20 characters (0-19).
What you want is simply this:
cin>>customer_name; // ditto for type and account_number
PLEASE USE CODE TAGS (the <> formatting button) when posting code. http://v2.cplusplus.com/articles/jEywvCM9/
It makes it easier to read your code and it also makes it easier to respond to your post.
Hint: You can edit your previous post, highlight your code and press the <> formatting button.