0

Hello, I am having an issue with C++. I am relatively new to this language.

The issue I am having is that I am unable to use a variable declared as private in my class.

Definition:

```
class Matrix
{
public:
Matrix(void);
Matrix(int rows, int cols);
Matrix(const Matrix& m);
~Matrix(void);
float GetM(int row, int col) const;
void SetM(int row, int col, float data);
Matrix& operator=(const Matrix &rhs);
Matrix operator*(const Matrix &matrix2);
int NumRows() const;
int NumCols() const;
void Resize(int rows, int cols);
private:
vector<vector<float>> _matrix;
void Copy(const Matrix& m);
};
```

When I try to access _matrix in the operator* function as follows:

```
Matrix Matrix::operator* (const Matrix &matrix2)
{
int i, j;
float sum;
Matrix result;
int i, j, k;
float sum;
for (i = 0; i < _matrix.NumRows(); i++) {
for (j = 0; j < matrix2.NumCols(); j++) {
sum = 0;
for (k = 0; _matrix.NumCols(); k++) {
sum += _matrix.GetM(i, k) * matrix2.GetM(k, j);
}
result.SetM(i, j, sum);
}
}
return result;
}
```

I get the error message:

IntelliSense: class "std::vector<std::vector<float, std::allocator<float>>, std::allocator<std::vector<float, std::allocator<float>>>>" has no member "GetM".

However, I am able to use _matrix in other classes without an issue:

```
float Matrix::GetM(int a, int b) const
{
return _matrix[a][b];
}
void Matrix::SetM(int a, int b, float x)
{
_matrix[a][b] = x;
}
void Matrix::Resize(int rows, int cols)
{
_matrix.resize(rows);
for(int i = 0; i < rows; i++)
{
_matrix[i].resize(cols);
}
}
```

Hopefully someonce can point out what I am doing wrong. I have tried searching Google for similar errors, but I am unable to find anything. maybe I am using the wrong search criteria.. Any help would be appreciated.