Click here to Skip to main content
15,894,546 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Window on Dialog Pin
Nishad S4-Jun-06 23:16
Nishad S4-Jun-06 23:16 
QuestionRe: Window on Dialog Pin
Manjunath S4-Jun-06 23:16
Manjunath S4-Jun-06 23:16 
AnswerRe: Window on Dialog Pin
Nishad S4-Jun-06 23:22
Nishad S4-Jun-06 23:22 
QuestionRe: Window on Dialog Pin
Manjunath S4-Jun-06 23:31
Manjunath S4-Jun-06 23:31 
AnswerRe: Window on Dialog Pin
Nishad S4-Jun-06 23:49
Nishad S4-Jun-06 23:49 
AnswerRe: Window on Dialog Pin
_AnsHUMAN_ 4-Jun-06 23:24
_AnsHUMAN_ 4-Jun-06 23:24 
GeneralRe: Window on Dialog Pin
Nishad S4-Jun-06 23:27
Nishad S4-Jun-06 23:27 
AnswerRe: Window on Dialog Pin
_AnsHUMAN_ 4-Jun-06 23:31
_AnsHUMAN_ 4-Jun-06 23:31 
QuestionRe: Window on Dialog Pin
Manjunath S4-Jun-06 23:47
Manjunath S4-Jun-06 23:47 
Questionabout edit box Pin
yogendra kaushik4-Jun-06 22:55
yogendra kaushik4-Jun-06 22:55 
AnswerRe: about edit box Pin
_AnsHUMAN_ 4-Jun-06 22:59
_AnsHUMAN_ 4-Jun-06 22:59 
AnswerRe: about edit box Pin
Hamid_RT4-Jun-06 23:05
Hamid_RT4-Jun-06 23:05 
AnswerRe: about edit box Pin
ThatsAlok5-Jun-06 0:26
ThatsAlok5-Jun-06 0:26 
Questionconfused about system stack Pin
George_George4-Jun-06 22:54
George_George4-Jun-06 22:54 
AnswerRe: confused about system stack Pin
Viorel.5-Jun-06 0:19
Viorel.5-Jun-06 0:19 
GeneralRe: confused about system stack [modified] Pin
George_George5-Jun-06 1:38
George_George5-Jun-06 1:38 
GeneralRe: confused about system stack [modified] Pin
Viorel.5-Jun-06 2:05
Viorel.5-Jun-06 2:05 
GeneralRe: confused about system stack [modified] Pin
George_George5-Jun-06 2:24
George_George5-Jun-06 2:24 
GeneralRe: confused about system stack [modified] Pin
Viorel.5-Jun-06 3:18
Viorel.5-Jun-06 3:18 
GeneralRe: confused about system stack [modified] Pin
George_George5-Jun-06 3:38
George_George5-Jun-06 3:38 
GeneralRe: confused about system stack [modified] Pin
Viorel.5-Jun-06 3:58
Viorel.5-Jun-06 3:58 
GeneralRe: confused about system stack [modified] Pin
George_George6-Jun-06 19:07
George_George6-Jun-06 19:07 
GeneralRe: confused about system stack [modified] Pin
Viorel.6-Jun-06 20:58
Viorel.6-Jun-06 20:58 
In declarations like

int * pi = new int[5];

you actually have two variables. First is pi, which is a pointer. It is allocated on the stack (in case of functions) or in data segment (if is outside of functions). The size of pi is usually four bytes. Another variable is the array allocated by new in heap area. This variable has no name, by has an address (for instance 0x1234), returned by new, which is assigned to the pi variable. The size of this array is twenty bytes.

Therefore the content of the pi variable is the address of the array, but not the content of array. When you use pi, you actually denote the address -- 0x1234. For instance, when you call a function, f(pi), you pass the 0x1234 value to the function, but not the content of array.

When you use delete pi, the unnamed array is deleted, but the pi variable is still available for another assignments.

In order to work with the referenced values via pointer, you use expressions like pi[3] or *(pi+3).

Actually, in case of data allocated on the heap, you can simulate an assignment of a name, using references. For instance:

int * z = new int;
int & r = *z;

In this case, r is a synonym for the integer allocated on the heap, and the usage of r will be treated as an access to this integer. For instance, r = 200 will assign a new value to that integer. Here, z still denotes an address, but r denotes the value on the heap. So, now that integer has a name -- r;

Internally, references are stored as pointers, i.e. they contain addresses of referenced variables. They are a convenient way for working with addresses, because "r" is simpler than "*z".

Therefore we can say that references offer a way for assigning names to variables allocated on the heap.

That is the picture in my opinion.
GeneralRe: confused about system stack [modified] Pin
George_George6-Jun-06 21:21
George_George6-Jun-06 21:21 
QuestionQuaternion rotation Pin
lastgen4-Jun-06 22:43
lastgen4-Jun-06 22:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.