Click here to Skip to main content
15,903,012 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: pointer [modified] Pin
jith - iii25-May-06 21:09
jith - iii25-May-06 21:09 
GeneralRe: pointer Pin
S. Senthil Kumar25-May-06 22:59
S. Senthil Kumar25-May-06 22:59 
GeneralRe: pointer [modified] Pin
jith - iii25-May-06 23:31
jith - iii25-May-06 23:31 
GeneralRe: pointer [modified] Pin
S. Senthil Kumar26-May-06 14:27
S. Senthil Kumar26-May-06 14:27 
GeneralRe: pointer [modified] Pin
jith - iii26-May-06 19:02
jith - iii26-May-06 19:02 
GeneralRe: pointer [modified] Pin
S. Senthil Kumar26-May-06 20:42
S. Senthil Kumar26-May-06 20:42 
GeneralRe: pointer [modified] Pin
jith - iii26-May-06 22:30
jith - iii26-May-06 22:30 
GeneralRe: pointer [modified] Pin
Stephen Hewitt26-May-06 18:05
Stephen Hewitt26-May-06 18:05 
In general what you say is correct. I have a minor correction to the following however:

S. Senthil Kumar wrote:
the compiler allocates a certain number of bytes (depending on the platform) on the stack.


This is not always the case: the pointer need not be allocated on the stack. In fact the allocation of storage is an issue that concerns any variable and not just pointers. Consider the following:

struct Data
{
    int number;
    int *pNumber;
};

// Code like this will allocate the memory for a "Data" struct on the stack.
// So the member "number" (not a pointer at all) and "pNumber" (is a pointer)
// will both be allocated on the stack.
void Function()
{
    Data IsOnTheStack;
    // Do stuff...
}

// Code like this will not use the stack.
// The memory will be in a data segment of the executable.
Data InDataSegment; // At global scope.

// Now code like this will place the struct (and its members) on the heap.
// The storage for the actual pointer "pData" may be on the heap, stack or
// a data segment in a module but the actual structure and it members are
// on the heap.
Data *pData = new Data;


So in short pointers need not be on the stack and in fact where they are is not related to the fact they are pointers but the context.


Steve
GeneralRe: pointer [modified] Pin
S. Senthil Kumar26-May-06 20:35
S. Senthil Kumar26-May-06 20:35 
AnswerRe: pointer [modified] Pin
Member 303984325-May-06 19:29
Member 303984325-May-06 19:29 
AnswerRe: pointer [modified] Pin
Saday Sarkar25-May-06 19:51
Saday Sarkar25-May-06 19:51 
GeneralRe: pointer [modified] Pin
jith - iii25-May-06 21:11
jith - iii25-May-06 21:11 
GeneralRe: pointer [modified] Pin
Stephen Hewitt26-May-06 18:25
Stephen Hewitt26-May-06 18:25 
GeneralRe: pointer [modified] Pin
jith - iii26-May-06 19:06
jith - iii26-May-06 19:06 
QuestionLinux's gettimeofday() equivalent for windows Pin
useme12325-May-06 18:41
useme12325-May-06 18:41 
AnswerRe: Linux's gettimeofday() equivalent for windows Pin
Ganesh_T25-May-06 18:51
Ganesh_T25-May-06 18:51 
GeneralRe: Linux's gettimeofday() equivalent for windows Pin
ThatsAlok25-May-06 22:18
ThatsAlok25-May-06 22:18 
AnswerRe: Linux's gettimeofday() equivalent for windows Pin
Nibu babu thomas25-May-06 18:53
Nibu babu thomas25-May-06 18:53 
AnswerRe: Linux's gettimeofday() equivalent for windows Pin
Ryan Binns25-May-06 18:57
Ryan Binns25-May-06 18:57 
QuestionAbout threading Pin
Aqueel25-May-06 18:30
Aqueel25-May-06 18:30 
AnswerRe: About threading Pin
Nibu babu thomas25-May-06 18:38
Nibu babu thomas25-May-06 18:38 
AnswerRe: About threading Pin
_AnsHUMAN_ 25-May-06 18:43
_AnsHUMAN_ 25-May-06 18:43 
AnswerRe: About threading Pin
ThatsAlok25-May-06 22:19
ThatsAlok25-May-06 22:19 
QuestionControl of a List Box Pin
Immunity1825-May-06 18:11
Immunity1825-May-06 18:11 
AnswerRe: Control of a List Box [modified] Pin
Nibu babu thomas25-May-06 18:20
Nibu babu thomas25-May-06 18:20 

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.