i'm trying to understand how to use new and while i was experimenting I came accross something i dont understand...
here is a quick example:
why does the compiler let me give var1 and var2 values at array index 100 if I only made a new integer the size of 2 array indexes ()? I thought the "new" was like calling malloc just a little nicer
var1 = new int;
var2 = new int;
var1 = 2;
var2 = 3;
var1 = 3;
printf("var1 = %d, var2 = %d\n", var1, var2);
printf("var1 = %d\n", var1);
here is the output f the program aswell
whats even more weird is that its actually being set to the right values 1 even tho i didnt allow that much space memory to be used when i used new!!!...now I really don get it..
var1 = 2, var2 = 3
var1 = 3
Press any key to continue
thanx for your help in advance,