for example

cout << "User Name: ";
		getline( cin, s.userName);
		cout << "Gender: ";
		cin >> s.gender();

but i can't use s.userName or s.gender, because they are protected value(incapsulation),
how do i use setUserName(string)/ setGender(char) together with getline/cin?

for example

cout << "User Name: ";
		getline( cin, s.userName);
		cout << "Gender: ";
		cin >> s.gender();

but i can't use s.userName or s.gender, because they are protected value(incapsulation),
how do i use setUserName(string)/ setGender(char) together with getline/cin?

cant you say

setUserName(getline());

Im also pretty new to c++ so Im not sure if that will work. Otherwise, just create a temp variable for the input

cant you say

setUserName(getline());

Im also pretty new to c++ so Im not sure if that will work. Otherwise, just create a temp variable for the input

tried that, doesn't work :/
I've thought of using temp variable, but is there any simpler alternative? because there'll be many temp variable if i do that...

tried that, doesn't work :/
I've thought of using temp variable, but is there any simpler alternative? because there'll be many temp variable if i do that...

Ive looked in my book, all I seem to find is something like this:

setUserName(std::cin);

Cant find anything else n the subject though

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.