Request for member when I call function

I'm writing a small c++ program which will be able to do a few things with a matrix. I have a class called Matrix and a member function in it called getSor() which returns an integer value about the number of lines in the matrix. When I call this getSor() function the program says:

error: request for member ‘getSor’ in ‘matrix’, which is of non-class type ‘Matrix*’

- 'matrix' is an existing Matrix object here
- I called the function like this: "cout << matrix.getSor() << endl;"

What am I doing wrong? Can you help me, please?

(Sorry for my bad English)
From that error message, it looks like you've defined matrix as a pointer to a Matrix object, rather than it actually being a Matrix object.

In C++, there's a handy bit of syntactical sugar to make dereferencing-and-accessing-a-member easy:

 
cout << matrix->getSor() << endl;
Last edited on
Topic archived. No new replies allowed.