#include<iostream>
#include<math.h>
#include<string>
using namespace std;
class houseinfo{
private:
string name;
string address;
int bed;
int price;
public:
void getdata(char string[],char string1[],int a,int b)
{
name=string;
address=string1;
bed=a;
price=b;
}
void display()
{
cout<<name<<" "<<address<<" "<<bed<<" "<<price<<endl;
}
void sort(){
houseinfo haw[2];
/*for(int i=0;i<2;i++){
}
for(int i=0;i<2;i++){
for(int j=0;j<2-1;j++){
if(haw[j].price<haw[j+1].price){
hold = haw[ j ].price;
haw[ j ].price = haw[ j + 1 ].price;
haw[ j + 1 ].price = hold;
}
}
}*/
for(int i=0;i<2;i++){
haw[i].display();
}
}
void display2()
{
cout<<" "<<price<<endl;
}
};
void main()
{
int temp=0;
int temp1=0;
houseinfo detail[2];
char string[15],string1[30];
int a,b;
houseinfo *ha;
for(int i=0;i<2;i++)
{
cout<<"Enter Owner Name:-"<<endl;
cin>>string;
cout<<"Enter Address please?"<<endl;
cin>>string1;
cout<<"Enter No Of BedRooms"<<endl;
cin>>a;
cout<<"Enter Price "<<endl;
cin>>b;
cout<<endl;
detail[i].getdata(string,string1,a,b);
//detail.display();
}
cout<<"***********INFORMATION***********"<<endl;
for(int j=0;j<2;j++)
{
detail[j].display();
}
ha=detail;
ha.sort();//Expression must have class type
for(int j=0;j<2;j++)
{
ha[j].display2();
}
}
Please use code tags when posting code, to make it readable.
You've declared ha
as a pointer, not an object with a class type:
houseinfo *ha;