show us exactly what you are trying to run.
the posted version has a mismatch in case, so line 71 fails it.
you can't cin to a function this way (to do that it would need to return a direct reference to the data, making the getter function moot -- its doable, but not cleanly).
so ..
string & country::globalize_name()
{
return name; //returns a reference to this
}
should let you say
cin >> globalize_name(); //this is very bad code. but you can do just about anything in c++ even when you should not!
if you want this, spare us the clutter and make name public. then its just
cin >> var.name
consider this, does it answer or help your issues?
1 2 3 4 5 6 7 8 9 10 11 12
|
int main() {
Country n, c, p, ct;
std::cout << "Enter Country:";
string s{"USA"};
n.setName(s);
cout << n.getName();
}
|
the bottom line is that things need to match up.
you have a method that takes a string, so you need to give it a string.
its the same thing as if it were not in a class.
you have this, with the class-gibbersh removed:
void foo (string s); //some function out there etc
..
cin >> foo(); //compiler is going to hate on this with all kinds of exciting messages.
the first tier (no inheritance, virtual, or other concepts) of OOP / classes works just like normal programming ... the methods are just like normal functions, except that have access to some "global to them" variables (the class's member variables). The fancy stuff moves beyond this a little but its still 'very like this' even when you get to the second tier studies.