>>How do we know the type the pointer points?
You have to declare the data type when the pointer is created. int* iPointer; >>Is it compiler specific?
No. Pointers are defined by C and C++ standards, so all compilers comply.
when we use int *p=new int; we know p point to int. But i just wanna know how the compiler know p's type?
Because you've told it so. int *p tells the compiler that p is a pointer to int. The compiler also knows that the expression "new int" yields a value of type pointer to int, that can stored in the pointer p.
If you want a self-respecting compiler to complain bitterly, tell it "int *p = new double;" : it recognises that "new double" does not yield a pointer to int, and complains about a mismatch of types.
When we delete a pointer to a array, how the compiler know how many bytes to release?
The compiler doesn't. All the compiler knows is that it's asked to delete an array (as in "delete  whatever;") because the  tells it that.
When dynamically allocating an array, you specifically tell it how many elements to allocate. There is nothing stopping code that manages memory allocation from keeping track of things, and retrieving the value when working with the delete operator. The methods of doing that, however, vary between compilers. And there is no portable way for your code to retrieve that value (unless you also keep track of such things yourself).
Hi I'm having a problem implementing a mini shopping cart drop down in the header to show the user all the products they have in their shopping cart. It seems the only solution for this is Ajax, and I've looked all over and can't find anything that I could possibly ...
Help! I want to create a java program that finds the highest even integer among the values entered by the user. Stop asking values when a value less than 1 have been entered. If no even integer is entered, display "No Even Integer"