I was playing with pointers and clases here i got stuck.Please help....
#include <iostream>
#define len 10
using namespace std;
class test{
private:
int *ar;
public:
test();
void foo();
};
test :: test(){
int arr[len];
for (int i =0 ; i < len; i++){
cin>>arr[i];
}
this->ar = arr;
}
void test::foo(){
for(int i = 0;i<len;i++)
cout<<this->ar[i]<<endl;
}
int main() {
test ob;
ob.foo();
return 0;
}
when im running the code i get this ouput..
[uzumaki@uzumaki-pc C_pros]$ ./a.out
1 2 3 4 5 6 7 8 9 10
1
0
810691180
21880
5
6
1713156944
32767
9
10
i expected the output should come
1
2
3
4
5
6
7
8
9
10
Please explain ...Thank you...