Need Help understanding this problem.. Help is needed urgantly!

a)Create a Document class to load the text document in memory. For this purpose the constructor of the class is in charge with creating a memory structure representing an array of pointers to string classes, each string class holding the content of one row. The array of pointers should grow by an increment of 10 each time it fills up with document’s rows. The document should be read from a text file, each sentence of the text file is captured in a string object. In the example below the text from the document is represented in abstract by rows of ‘a’, ‘b’, etc. This class should be tracking the size of the array of pointers, the number of rows loaded, and provide an interface getRow(int nr) function to return the content of a particular row (verify for document overflow).

I am not understanding what is needed from me or how to even start working on this. I was hopeing that someone could point me in the right direction or provide a tell where I can get a simalar example to learn from?

Any help would be much appreciated!
, I don't understand how big the array pointers needs to be or how to increment it by 10 each time it fills. How do tell that it has filled up. I think I'll need a buffer to keep track, But I don't know how to implement it.
This is what I have in my Header so far:
#ifndef DOCUMENT_H
#define DOCUMENT_H
class Document
{
char *lines;
public:
Document(char *fname);
int getRow(int nr);
};

#endif

And this is the class implementation:
#include<iostream>
#include<fstream>
#include<string>
#include"Document.h"

using namespace std;

Document::Document(char *fname)
{
int i=0;
lines = new char[10];
ifstream in;
in.open(fname);
if(!in)
{
cout<<"Error: Can't open the file!"<<endl;
exit(1);
}
else
{
while(in)
{
getline(in,lines[i],'.');
++i;
}
}
}
Last edited on
Well, first you need to create a class, called Document.

The class needs to own
a memory structure representing an array of pointers to string classes
.

Each string object in the array needs to hold
the content of one row
of the document.

You need to write a method or methods that allow the document to
should be read from a text file
, such that
each sentence of the text file is captured in a string object
.

Etc, etc. The description seems pretty clear on what's required, and provides some helpful advice on how to implement it.
Last edited on
Topic archived. No new replies allowed.