class Customer {
private:
char name[50];
int acc_no;
char acc_type;
float balance;
public:
void getData();
};
int main() {
Customer cust;
cust.getData();
cust.getData();
}
void Customer::getData() {
cout<<"Name : ";
cin>>name;
cout<<"Acc No. : ";
cin>>acc_no;
cout<<"Acc Type : ";
cin>>acc_type;
}
The second time I call the function getData of customer class, I does not ask me for the name. I have tried gets(), cin.getline. Again, the same problem.
Also, how can I prevent input of characters other than numbers in integers, float etc?