I got an error: cannot convert from 'int (A: )[10]' to 'int A: ' in second line of 'main()'
I tried to remove '&' from this line because x is an array so the name of array (without square brackets) like A::x should return it's adress (in this case shift in A class), but now I got an error like this:
illegal reference to non-static member 'A::x'
Why compiler thinks I want to convert something? I just want to create a pointer to int array x[10], member of A class.
Could you help?
Re: Pointers to class members - it just won't work.
>I feel I was not understood again, propably my fault.
Don't worry about it. Pointers to members aren't exactly a commonly used feature. The problem in your initial code is a type mismatch. x is an array, but to get a pointer to it, you need a pointer to an array member and you were only using a pointer to an int member:
Unfortunately, this isn't a case where you can rely on the implicit conversion of an array name to a pointer to the first element of the array. To do that you would need to add another level of abstraction:
No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.