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?

Edited 7 Years Ago by Qmage: n/a

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...

Edited 7 Years Ago by Qmage: n/a

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

This article has been dead for over six months. Start a new discussion instead.