I am using the dereference operator but I don't seem to getting values of x.
#include <iostream>
using namespace std;
class Array {
public:
int* get() {
int x[] = { 31, 45, 39, 32, 9, 23, 75, 80, 62, 9 };
int *r;
r = x;
return r;
}
};
int main() {
Array arr;
int *temp = arr.get();
for (int i = 0; i < 10; ++i) {
cout << temp[i] << " ";
}
}
This prints out 31 32765 0 0 0 0 -1989689609 32624 -989639072 32765 rather than 31 45 39 32 9 23 75 80 62 9