it omits the name of owner second time in loop

#include<iostream>
#include<string>
using namespace std;
class Household{
private:
string ownerName;
string address;
int bedrooms;
long int price;

public:
void getData(string a,string b, int q,long int r){
ownerName=a;
address=b;
bedrooms=q;
price=r;
}
void display(){
cout<<ownerName<<" "<<address<<" "<<bedrooms<<" "<<price<<endl;


}

};

void main(){
Household name[3];
string aw,bw;
int qw;
long int rw;
for(int i=0;i<3;i++){
cout<<"Enter house holder name ";
getline(cin, aw);
cout<<"\nenter address ";
getline(cin, bw);
cout<<"enter no of bedrooms";
cin>>qw;
cout<<"enter the price of house ";
cin>>rw;
name[i].getData(aw,bw,qw,rw);
}
for(int i=0;i<3;i++){
name[i].display();}
}
Topic archived. No new replies allowed.