I have a Data class that contains a VectorXf object from the Eigen Template Library. This vector object has a constructor that accepts an int defining how much memory to allocate. However, this number is not known at compile time.
Anyway, what I am trying to do is declare the VectorXf object in my Data class header file, then construct that VectorXf object during construction of my Data object. I'm new to c++, so I am a little confused on how to do this. I keep getting an error that says undefined reference to Data::vector(int) What am I doing wrong?
Here is the Header file Data.h for my Data class:
#ifndef DATA_H
#define DATA_H
#include <Eigen/Eigen>
using namespace Eigen;
using namespace std;
class Data
{
    public:
        Data(string file);
        virtual ~Data();
        void readFile(string file);
    private:
        VectorXf vector(int n);
};
#endif // DATA_H
So, as you can see from the header file above, a data object contains a vector object that takes an integer as a parameter.
Here is the Data.cpp file:
#include "Data.h"
#include <iostream>
#include <string>
#include <Eigen\Eigen>
#include<fstream>
using namespace Eigen;
using namespace std;
Data::Data(string file)
{
    readFile(file);
}
void Data :: readFile(string file){
    int n = ... // read file length using fstream
    vector(n); //construct the VectorXd object that was declared in Data.h
}   
Data::~Data()
{
    //dtor
}
For clarity, what needs to happen in my main function:
   Data data("myfile.txt")
which creates a Data object. Then a file length is read since the Data constructor calls readFile(), which determines the appropriate length to construct the VectorXf object that is a Data class member. What is the proper way of referring to and constructing my class member objects - VectorXf vector in this case.
