Q3: Continue with House class: a) Copy the previous program to a new file. b) Overload the insertion operator << to output House objects. c) Overload the extraction operator >> to input House objects. Use following main() to test your class. int main(){ House a("1234 qcc st, Bayside, NY",1000000); cout<>a; cout<
**please see question attached** (previous program below)
#include <iostream>
using namespace std;
class House{
//instance variables
private:
string location;
int price;
public:
//constructors
House(){
location = "TBD";
price = 0;
}
House(string location,int price){
this->location = location;
this->price = price;
}
//Get and set methods
void setLocation(string location){
this->location = location;
}
string getLocation(){
return location;
}
void setPrice(int price){
this->price = price;
}
int getPrice(){
return price;
}
};
//member function
void output(House a){
cout <<"Location: " << a.getLocation()<<endl;
cout <<"Price: "<<a.getPrice()<<endl;
}
int main()
{
House a("1234 qcc st, Bayside, NY",1000000);
output(a);
House b;
output(b);
return 0;
}
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images