| | |
any articles or books about pointer?
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
Seek and thou shalt find.
>>How do we know the type the pointer points?
You have to declare the data type when the pointer is created.
>>Is it compiler specific?
No. Pointers are defined by C and C++ standards, so all compilers comply.
>>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.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
•
•
Join Date: Aug 2008
Posts: 206
Reputation:
Solved Threads: 31
•
•
•
•
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?
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?
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).
![]() |
Other Threads in the C++ Forum
- Previous Thread: Syntax Error
- Next Thread: visual c++ 2005 how to resolve?
| Thread Tools | Search this Thread |
api array arrays based beginner binary c++ c/c++ calculator char char* class classes code compile compiler console conversion count delete deploy desktop directshow dll download dynamic dynamiccharacterarray encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker linux list loop looping loops map math matrix memory news number numbertoword output parameter pointer problem program programming project python random read recursion recursive reference return rpg sorting string strings struct temperature template templates test text text-file tree unix url variable vector video visual visualstudio win32 windows winsock wordfrequency wxwidgets






