I've been starting to put all my variables in private, and since i've been doing that I have no idea how to do anything anymore. Before if I wanted to name something I could just do something like string name; then cin >> name;
I've been trying to figure out how to do this while making them private and can't make it work. I still don't even know what im suppost to have in my class and what not to have in it.
#include <iostream>
#include <string>
usingnamespace std;
class Q{
public:
void setsword(string x){
Sword = x;
}
string getsword(){
return Sword; }
private:
string Sword;
};
int main(){
char response;
cout << "You are walking through a forest and discover clearing with a giant rock in the middle. You go up to the rock and discover a sword stuck in the middle of it." << endl;
cout << "Do you want to attempt to pull the sword out? y/n" << endl;
cin >> response;
if (response == 'y'){
cout << "You walk up to the sword and attempt to pull it out with all your strength, but it doesn't seem to come out." << endl;
cout << "Keep trying? y/n";
}
cin >> response;
if (response == 'y'){
cout << "SUCCESS!!! You manage to pull the sword out, What would you like to call your new sword?" << endl;
Q inwin;
cin >> inwin.setsword(); //right here is what i'm having problems with
}
return 0;
}