Search code examples
c++classmember

request for member ... which is of non-class type


I get the error

main.cpp: In function 'int main()':
main.cpp:43:16: error: request for member 'getF' in 'cor', which is of non-class type 'corMatrixFermion(MatrixV)'
  myfile << cor.getF;
                ^

Here is the Header of my class:

class MatrixV{
  public:
    MatrixV(std::string file);
    MatrixV(Eigen::MatrixXd matrix);
    MatrixV(double arr[], int arrsize);

    Eigen::MatrixXd getV();
    Eigen::VectorXd getSigma();
    int getr(); 
    Eigen::MatrixXd getO1();
    Eigen::MatrixXd getO2();
    Eigen::MatrixXd getE(); 
    Eigen::MatrixXd getVStrich();

private:
    int size;
    Eigen::MatrixXd V;
    Eigen::VectorXd Sigma;
    int r;
    Eigen::JacobiSVD<Eigen::MatrixXd, Eigen::NoQRPreconditioner> svd;
};

And here the main.cpp

int main(){
std::srand(time(0));

DataFromFile StartValues("StartValues");

double arr[4];
arr[0]  = StartValues.get(1);
arr[1]  = StartValues.get(2);
arr[2]  = StartValues.get(3);
arr[3]  = StartValues.get(4);

MatrixV V(arr, 4);
corMatrixFermion cor(MatrixV V);

std::ofstream myfile;
myfile.open ("corfunction.txt");
myfile << cor.getF();
myfile.close();
}

There are other classes involved, but I dont think, that they cause the problem. Do you see, what I'm doing wrong? If you need more information please tell me. It seems to me, that it is not the usual "request for member"-constructor-problem. But maybe I'm wrong...


Solution

  • This looks dodgy:

    corMatrixFermion cor(MatrixV V);
    

    This is declaring cor to be a function. You probably meant to pass V to the corMatrixFermion constructor instead:

    corMatrixFermion cor(V);