У меня проблемы с сохранением данных, считываемых с клавиатуры, в массив приватных членов.
Когда я пытаюсь просто добавить данные, используя:
std::cin >> array[counter];
Я получаю длинную ошибку: вставлено сюда для экономии места
В настоящее время я пытаюсь найти способ сохранить входные данные во временную переменную и затем отправить их в массив, но я получаю ту же ошибку.
Заголовок:
template<class Type>
class Department
{
private:
const static int MAX = 4;
typedef std::string sArray[MAX];
typedef Type tArray[MAX];
std::string deptName;
sArray names;
tArray salary;
public:
Department(const std::string & dept);
bool Add() const;
...
...
};
Реализация:
template<class Type>
Department<Type> :: Department(const std::string & name)
{...}
template<class Type>
bool Department<Type> :: Add() const
{
if (IsFull())
return 0;
else
{
Type tempName;
Type tempSal;
std::cout << "\nAdd called\n";
std::cout << "Enter employee ID:\t"; std::cin >> tempName;
std::cout << "Enter employee salary:\t"; std::cin>>tempSal;
//What is the best way to add the data stored in tempName, and tempSal to the arrays in the class
return 1;
}
}
Ссылка на MCVE