Large data object - declaration, creation, deletion - where should it be done

I have a class which I am trying to implement. This class will be responsible for accessing a large data set - for e.g., 200,000 English words. The data will be stored in a vector (vector<string>).

I am not sure (based on good design practices) whether the class I am implementing should have a private data member declaring the vector? If not, where else could I define the data object, and how should it be managed (creation, deletion, etc.).

I know my question is very generic. I am learning C++ on my own, so I would appreciate any guidance and help. And please correct me if I am asking the question in a wrong way.
Last edited on
I'd start like this:

1
2
3
4
5
class DataSet
{
  public:
  vector<string> theData;
}


Then start using it. As you find functionality you need, you'll add it. As you find how it should be used, you'll make member variables public or private accordingly.
Last edited on
So, for example:
If my class was going to be as follows, would this be the right way of doing it?

1
2
3
4
5
6
7
8
9
class MyClass
{
    private:
        vector<string> myList;

    public:
        void AddToList(string str);
        vector<string> GetAllFromList();
}


Next question: I am reading a lot about unit testing. If the above was my class, would my unit test be as simple as this:
1. Create a class, e.g. MyTestClass with various test functions/methods, for which each function/method would create a MyClass object, call the AddToList() and GetAllFromList() functions and verify that the read values match the expected values (e.g. corner cases, null, empty strings, duplicates, etc?)
2. In main(), call the functions I created in MyClass

Sorry for deviating from my original topic. Just trying to learn a few things along the way.
Last edited on
Topic archived. No new replies allowed.