I'm trying to change my basic array so I will instead be using the array class. How can I do this while still calling from the class Record? (in main.cpp)
Record.h
#include <cstdlib>
#include <iostream>
#include <string>
#include <array>
#include "Record.h"
usingnamespace std;
class Recordsbook
{
array<string, 10> Record book;
public:
void Menu()
{
int choice = 0;
cout << "---Main Menu---\n";
cout << "1. Input information\n";
cout << "2. Display records\n";
cout << "3. Exit\n";
cin >> choice;
switch (choice)
{
case 1:
InputInfo();
break;
case 2:
Display();
break;
case 3:
Exit();
break;
}
}
void InputInfo()
{
for(int i = 0; i<10; i++)
{
cout << "What is the record number? ";
string r = "";
cin >> r;
book[i].setRecNum(r);
cout << "What is the first name? ";
string f = "";
cin >> f;
book[i].setFirstName(f);
cout << "What is the last name? ";
string l = "";
cin >> l;
book[i].setLastName(l);
cout << "What is the age? ";
string a = "";
cin >> a;
book[i].setAge(a);
cout << "What is the telephone number? ";
string t = "";
cin >> t;
book[i].setTelephone(t);
}
Menu();
};
void Display()
{
int i = 0;
for(i=0; i<10; i++)
{
cout<<"Record number: ";
cout<<book[i].getRecNum();
cout<<"\n";
cout<< "First name: ";
cout<<book[i].getFirstName();
cout<<"\n";
cout<< "Last name: ";
cout<<book[i].getLastName();
cout<<"\n";
cout<< "Age: ";
cout<<book[i].getAge();
cout<<"\n";
cout<< "Telephone number: ";
cout<<book[i].getTelephone();
cout<<"\n";
cout<<"\n";
}
Menu();
};
void Exit()
{
cout << "Closing...";
};
} Recordsbook;
int main()
{
Recordsbook.Menu();
}
Array is in line 10. Tried to change it to array<string, 10> Record book; but that gives, for example, 'unable to resolve identifier setRecNum' errors at every book[I].set line. (lines 40, 44, 48, 52, 56, 66, 69, 72, 75, and 78) and I do not know how to code those lines so they do not cause errors.