Я пытаюсь вызвать функции из моего класса clsFamily в main, однако, когда я передаю (& objUser), я получаю сообщение о том, что
идентификатор 'objUser' не определен
Редактировать: Извините, забыл упомянуть, но я хочу динамический c векторный массив, который управляется на основе выбора пользователя.
Любая помощь будет любезно оценена, так как она для назначения, которое должно произойти в следующий четверг xD
int UserChoice();
int UserChoice()
{
int iChoice = 0;
int iAdults = 0;
int iChildren = 0;
cout << "How many family members do you have? \n";
cin >> iChoice;
cout << "How many of these are adults? \n";
cin >> iAdults;
cout << "How many of these are children? \n";
cin >> iChildren;
return iChoice;
return iAdults;
return iChildren;
}
class clsUser
{
private:
string m_sName;
int m_iAge;
public:
void SetName(string);
string GetName();
void SetAge(int);
int GetAge();
clsUser();
~clsUser();
clsUser(string, int);
};
//This is to group the singular users into a group using a vector
class clsFamily
{
private:
vector <clsUser> objUser;
public:
void InputFamilyDetails(vector <clsUser> *objUser);
void OutputFamilyDetails(vector <clsUser> *objUser);
};
void clsFamily::InputFamilyDetails(vector <clsUser>* objUser)
{
string sName = "";
int iAge = 0;
for (int iCount = 0; iCount < objUser->size(); iCount++)
{
cout << "Please enter the name of family member " << iCount + 1 << "\n";
cin >> sName;
cout << "Please enter the age of family member " << iCount + 1 << "\n";
cin >> iAge;
objUser->at(iCount).SetName(sName);
objUser->at(iCount).SetAge(iAge);
}
}
//This is to allow the user to input the the details of the users from the vector
void clsFamily::OutputFamilyDetails(vector <clsUser>* objUser)
{
for (int iCount = 0; iCount < objUser->size(); iCount++)
{
cout << "The name of family member " << iCount + 1 << " is " << objUser->at(iCount).GetName() << " \n";
cout << "The age of family member " << iCount + 1 << " is " << objUser->at(iCount).GetAge()<< " \n";
}
}
int main()
{
clsFamily objFamily;
*//This is the area where the problem is occuring*
objFamily.InputFamilyDetails(&objUser);
objFamily.OutputFamilyDetails(&objUser);
}