I am trying to ascertain the reason behind this compiler error which is ‘No matching function call to address::set_street(); Any advice would be much appreciated – thanks
#include <iostream>
#include <string>
using namespace std;
class address {
public:
address();
void set_street(string street) {
streetname = street;
};
string get_street() {
return streetname;
};
void set_parish(string parish) {
parishname = parish;
}
string get_parish() {
return parishname;
}
void set_country(string country) {
countryname = country;
}
string get_country() {
return countryname;
}
private:
string streetname;
string parishname;
string countryname;
};
int main(int argc, char* argv[]) {
system("color 0c");
address enteredaddress;
cout<<"Enter street name" <<endl <<endl;
cin >>enteredAddress.set_street();
cout<< endl;
system ("pause");
return 0;
}
This is not how the I/O works in C++: you cannot read from a stream and pass the result to a setter like that. You need to read the street into a variable first, and then pass that var to set_street: