#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
#include <cstdlib>
#include "Action.h"
#include "Action.cpp"
usingnamespace std;
void readCSV(istream &input, vector< vector<string> > &output)
{
string csvLine;
// read every line from the stream
while( getline(input, csvLine) )
{
istringstream csvStream(csvLine);
vector<string> csvColumn;
string csvElement;
// read every element from the line that is seperated by commas
// and put it into the vector or strings
while( getline(csvStream, csvElement, ',') )
{
csvColumn.push_back(csvElement);
}
output.push_back(csvColumn);
}
}
int main()
{
fstream file("bones.csv", ios::in);
if(!file.is_open())
{
std::cout << "File not found!\n";
return 1;
}
// typedef to save typing for the following object
csvVector csvData;
readCSV(file, csvData);
Queries queries(csvData);
system ("PAUSE");
return 0;
}
#include "Action.cpp"
Don't ever include .cpp files like this. After everything has been compiled the linker takes all of the .cpp files and puts them into the final executable file, as long as you have the correct header files included (which you do) it will be able to see all of the methods/members.
Containers in C++ use zero based indexing. This means they go from 0 - one size less than the total amount. In this case you will want to change for(size_t i = 0; i <= csvData.size();++i)
to for(size_t i = 0; i < csvData.size();++i)
so it doesn't go out of bounds on the vector.
If it isn't working after those fixes you might want to use a debugger and go through your code slowly and see where exactly it has the problem.