There is no mother class, stringV is a direct private member of the StringTable Class
Here are the two header files:
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
|
////////////////////////////////////////
// stringUtil.h
#ifndef _STRING_UTIL_H
#define _STRING_UTIL_H
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
////////////////////////////////////////
// 'readMultiWord' reads a multiword string
// terminated by 'sep' from 'infile' into 's'
// Example: if 'infile' contains "Los Angeles # California"
// then "Los Angeles" is stored in 's' and
// position of 'infile' is now at "California"
bool readMultiWord(string & s, ifstream & infile, const string & sep = "#");
#endif
////////////////////////////////////////
// StringTable.h
#ifndef _STRING_TABLE_H
#define _STRING_TABLE_H
#include <iostream>
#include <fstream>
#include <vector>
#include "stringUtil.h"
using namespace std;
////////////////////////////////////////
class StringTable
{
public:
////////////////////////////////////////
// 'StringTable' constructor
// reads in a 2D table of multiword strings
// from file 'infile'
// each multiword is separated by "#";
// each row is separated by an extra "#";
// yet another extra "#" at the end of rows
// Example (2 rows, 3 columns):
// Los Angeles # California # USA # #
// New York City # New York # USA # #
// #
StringTable(ifstream & infile);
////////////////////////////////////////
// 'rows' returns the number of rows
int rows() const;
////////////////////////////////////////
// operator [] returns row at index 'i';
// accessor (not a mutator);
// returns a reference but not mutable;
// TODO: write prototype, be careful about
// value vs. reference vs. constant reference
vector<string> &operator[](int);
private:
vector<vector<string> > stringV;
};
#endif
|
EDIT: The error that reoccurs at every instance where I use the operator is
StringTable.h:46: error: 'std::vector<std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >,
std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >, std::allocator<std::vector<std::basic_string<char,
std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > > >
StringTable::stringV' is private
and then it mentions that there is an error in the portion of the StringTableTester code where the operator is used.