I try to take input from the user with using set and get functionsin different member function. This functions are member functions of same class.
This just sounds like basic class design. Have you gone over what classes are? Do you know how to make a member function?
See examples at:
https://cplusplus.com/doc/tutorial/classes/
Just as another example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
class Student {
public:
void setName(std::string name)
{
this->name = name;
}
std::string getName()
{
return name;
}
private:
std::string name;
};
| |
For user input, you can use
cin.
See
https://cplusplus.com/doc/tutorial/basic_io/
1 2 3 4 5 6
|
Student student;
cout << "Enter name: ";
string name;
cin >> name;
student.setName(name);
cout << student.getName() << '\n';
| |
Last edited on