Sending a vector to function for sorting

I'm working on a input file conversion from a FORTRAN-based program to a C++-based program. There are multiple sections of the input file that look like:

1009 9 -0.91 801 -802 811 -34 824 -1005 $5
or
2 s -76.175 -60.85 -122.325 2.3372
etc.

and I need to sort the data based on sections which I plan to do through different classes such the Volume one you see below. I'm not quite to the actual sorting part of the code yet but I am trying to read these lines in a strings and then pass them to the class they need for their sorting.
Right now in an effort to find the source of the error I've removed the StringToInt/StringToDouble conversion I'll use later to sort them.

Here's the error I can't find the source of:


Undefined symbols:
"Volume::ProduceVectorForSorting(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> > > >)", referenced from:
_main in ccolwjig.o
"Volume::Volume()", referenced from:
_main in ccolwjig.o
ld: symbol(s) not found
collect2: ld returned 1 exit status

when I try to compile my program. Here is the program thus far:

Main program:

#include <string>
#include <vector>
#include <fstream>
#include <iostream>
#include <ios>
#include <sstream>

#include "include/Conversion.hh"
#include "include/Volume.hh"

#pragma hdrstop

// Read a file into two vectors, one overall vector and one line vector

void help(char *program)
{
std::cout << program;
std::cout << ": Need a filename for a parameter.\n";
}



int main(int argc, char* argv[])
{
int lineBreakCount = 0;
if (argc < 2) { help(argv[0]); return 1; }
std::vector<std::string> input;
std::string line;
std::vector<std::string> inputLine;
input.clear();
std::ifstream infile (argv[1], std::ios_base::in);
while (getline(infile, line, '\n'))
{
if(line.empty()) lineBreakCount += 1;
if(!line.empty()) input.push_back (line);
std::string token;
std::istringstream iss(line);
inputLine.clear();
while ( getline(iss, token, ' ') )
{ if( !line.empty() && !token.empty() ) inputLine.push_back(token); }
Volume* myVolume = new Volume();
myVolume->ProduceVectorForSorting(inputLine);
if(inputLine[0] != "c")
{ for(int j=0; j<inputLine.size(); j++) std::cout << " " << inputLine[j]; std::cout << std::endl; }
else std::cout << "Comment found" << std::endl;
}

return 0;
}


The Volume Header file:

#ifndef Volume_h
#define Volume_h 1

#include "Conversion.hh"
#include <vector>

class Converter;
class Volume
{
public:
Volume();
~Volume();

void ProduceVectorForSorting(std::vector<std::string> input);

private:
int cell;
string material;
double density;
int xStart, xEnd;
int yStart, yEnd;
int zStart, zEnd;
string comment;

public:

std::vector<std::string> volume;
std::vector<std::vector<std::string> > all_the_volumes;

};

#endif

The Volume source file:

#include Volume.hh
#include <fstream>
#include <vector>

Volume::Volume()
{ }

Volume::~Volume()
{ }

void Volume::ProduceVectorForSorting(std::vector<std::string> input)
{
cell = input[0];
material = input[1];
density = input[2];
xStart = input[3];
xEnd = input[4];
yStart = input[5];
yEnd = input[6];
zStart = input[7];
zEnd = input[8];

volume.push_back(cell);
volume.push_back(material);
volume.push_back(density);
volume.push_back(xStart);
volume.push_back(xEnd);
volume.push_back(yStart);
volume.push_back(zStart);
volume.push_back(zEnd);

}

I'd greatly appreciate any help you can provide.

Thanks
It seems like you don't compile the Volume source file. What IDE are you using? There should be something about adding that cpp to the project..
Right, thank you
Topic archived. No new replies allowed.