Error: Request for member '..' in '..' is of non-class type '..'

Viewed 20

Here is a similar example of the code that's causing the error:

class a {
public:
  int x;
  int y;
};

class b {
public:
  void func(a A, int k) {
      A.x = k;
    }
};

The error message for this would be as follows:

main.cpp:8:7
Request for member 'x' in 'A', which is of non-class type 'int'.

I have, for some reason, tried to pass in the 'a' type object into the function by reference as:void func(a& A, int k) but that doesn't seem to work either.

I hope there is an obvious error that I can solve without compromising much of my code structure.

0 Answers
Related