Error somewhere here:

class Array { int size; int* ar; public: Array(int _size): size(_size), ar(NULL) { if (size > 0) { ar = new int[size]; } } ~Array() { if (ar) { delete[]ar; } } int* GetArray() const { return ar; } int GetSize() const { return size; } void show() { if (size > 0) { for (int i = 0; i < size; i++) { cout << *(ar + i); } } } }; 

Studio gives:

2x:

C3867 'Array :: GetArray': non-standard syntax; use '&' to create a pointer to member.

Call:

 Array p(a); for (int i = 0;i < p.GetSize();i++) { p.GetArray[i] = 0; } cout << endl; p.show; 

    1 answer 1

    Right here

     p.GetArray[i] = 0; 

    You forgot to call the function:

     p.GetArray()[i] = 0; 

    You have a pointer to a method, not a pointer to an int .

    • Thanks, still needed in p.show () - Adam Hodovanets
    • And, yes, but I looked only at the error message that you brought, and answered it. - Harry
    • If you are satisfied with the answer - mark it as accepted ... - Harry