I have this code:
in my judgement it should print 1 and 2, instead it prints 0 and 1
some advice pls... Im using dev c++
#include <iostream>
class A
{
public:
A()
{
arr = new int[2];
}
~A(){ delete [] arr; }
int * arr ;
};
int main()
{
int * n ;
{//induced code block
A aObj;
aObj.arr[0] = 1;
aObj.arr[1] = 2;
n = aObj.arr;
/*
BTW I assume n now points to the same add of aObj.arr ... am I wrong??
*/
}
std::cout << "\n" << (*n) << " " << (*n+1);
system("pause");
}