Is this set up correctly?

Could somebody just tell me if I have my vector set up in my class correctly?

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
  //  WorkerBee.cpp

#include "WorkerBee.h"
#include "Vector.h"
#include "Tools.h"
#include<string>
using namespace tools;
using namespace std;

void tester(void)
{
    Vector myVector;
    Pairs myPair;
    
    string userWords;
    cout << "Enter list of words (-1 to stop): ";
    cin >> userWords;
    
    myPair.setWord(userWords);
    
    while ( userWords != "-1" )
    {
        myVector.addWords(myPair);
        cin >> userWords;
    }
    
}

class Vector
{
public:
    typedef std::vector<string> storage_type;
    typedef storage_type::size_type size_type;
    
    void addWords(string userInput);
    
private:
    storage_type words;
    size_type size;
    size_type currentWord;
};

void Vector::addWords(string userInput)
{
    words.push_back(userInput);
}

The members size and currentWord have no purpose. Client code has no read access to the words.

The lines 29-46 are presumably in Vector.h and not after the tester?

The tester can insert "-1" as a word.
Topic archived. No new replies allowed.