the only thing wrong about the following code is friendship, once I chance the data from private to public, it compiles. so why the friend declaration did let me go through?
Code:
#include <iostream>
#include <vector>
#include <string>
#include <fstream>
#include <sstream>
using namespace std;
class READER{
class DATA {
vector<string> rowtypes;
vector<string> rownames;
class rows;
friend class rows;
};
class state {
public:
virtual bool parse(const char* a, DATA& r) = 0;
};
class rows: public state {
public:
bool parse(const char* a, DATA& r) {
istringstream is(a);
string s1, s2;
is >> s1;
is >> s2;
if (is.fail())
return false;
r.rowtypes.push_back(s1);
r.rownames.push_back(s2);
return true;
}
};
};