V
voidtwerp
Hi,
I hope this is not too OT but I would like clarification on how classes
are held in memory.
each object obviously has an individual copy of its data.
I guess a class would only have one copy of its functions held in
memory (not sure what part of memory this would be refered to as).
Then whenever an object has a function called on it this function would
be copied onto the stack - am I right?
But then this should cause problems if the returned pointer is used
after the function has been replaced on the stack but it works
perfectly well - so what exactly is stored where?
char * MyClass::MyFunc(int selection)
{
switch(selection)
{
case 1:
return "one";
case 2:
return "two";
default:
return "no selection";
}
}
thanks in advance for your time.
I hope this is not too OT but I would like clarification on how classes
are held in memory.
each object obviously has an individual copy of its data.
I guess a class would only have one copy of its functions held in
memory (not sure what part of memory this would be refered to as).
Then whenever an object has a function called on it this function would
be copied onto the stack - am I right?
But then this should cause problems if the returned pointer is used
after the function has been replaced on the stack but it works
perfectly well - so what exactly is stored where?
char * MyClass::MyFunc(int selection)
{
switch(selection)
{
case 1:
return "one";
case 2:
return "two";
default:
return "no selection";
}
}
thanks in advance for your time.