array class

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
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include <cstdlib>
#include <iostream>
#include <string>
using namespace std;

#ifndef RECORD_H
#define RECORD_H

class Record
{
private:
    string recNum;
    string firstName;
    string lastName;
    string age;
    string phoneNum;
public:
    Record()
    {
    }
    
    Record(string recIn) :recNum(recIn)
    {
    }
    
    Record(string recIn, string fnameIn, string lnameIn, string ageIn, string phoneIn)
            :recNum(recIn), firstName(fnameIn), lastName(lnameIn), age(ageIn), phoneNum(phoneIn)
    {
    }
    //set functions
    void setRecNum(string recIn);
    void setFirstName(string nameIn);
    void setLastName(string nameIn);
    void setAge(string ageIn);
    void setTelephone(string phoneIn);
    //get functions
    string getRecNum();
    string getFirstName();
    string getLastName();
    string getAge();
    string getTelephone();
};

#endif /* RECORD_H */ 


Record.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include "Record.h"
#include <string>
using namespace std;

void Record::setRecNum(string recIn)
{
    recNum = recIn;
}

void Record::setFirstName(string nameIn)
{
    firstName = nameIn;
}

void Record::setLastName(string nameIn)
{
    lastName = nameIn;
}

void Record::setAge(string ageIn)
{
    age = ageIn;
}

void Record::setTelephone(string phoneIn)
{
    phoneNum = phoneIn;
}

string Record::getRecNum()
{
return recNum;
}

string Record::getFirstName()
{
return firstName;
}

string Record::getLastName()
{
return lastName;
}

string Record::getAge()
{
return age;
}

string Record::getTelephone()
{
return phoneNum;
}


main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#include <cstdlib>
#include <iostream>
#include <string>
#include <array>
#include "Record.h"
using namespace 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.
Last edited on
Line 10 needs to be:

array<Record, 10> book;

string doesn't make sense there.
Topic archived. No new replies allowed.