C
cweisbrod
All,
I'm seeing something very strange and was hoping someone might have
some insight into the cause of what I'm seeing. I have the following
scenario:
Platform: Microsoft Windows XP Pro, Visual Studio 2005
Code:
/////////////////////
class Parent
{
int parentData;
};
class Child : public Parent
{
char childData1;
int childData2;
};
void theFunction(Parent* inParent)
{
printf("inParent = %X\n", inParent);
}
int _tmain(int argc, _TCHAR* argv[])
{
Child* theChild = new Child;
if (theChild)
{
printf("theChild = %X\n", theChild);
theFunction(theChild);
delete theChild;
}
return 0;
}
/////////////////////
I get the following output:
theChild = 27373F0
inParent = 27373F4
Why would the address be different in the theFunction?
Thanks for any replies at all.
I'm seeing something very strange and was hoping someone might have
some insight into the cause of what I'm seeing. I have the following
scenario:
Platform: Microsoft Windows XP Pro, Visual Studio 2005
Code:
/////////////////////
class Parent
{
int parentData;
};
class Child : public Parent
{
char childData1;
int childData2;
};
void theFunction(Parent* inParent)
{
printf("inParent = %X\n", inParent);
}
int _tmain(int argc, _TCHAR* argv[])
{
Child* theChild = new Child;
if (theChild)
{
printf("theChild = %X\n", theChild);
theFunction(theChild);
delete theChild;
}
return 0;
}
/////////////////////
I get the following output:
theChild = 27373F0
inParent = 27373F4
Why would the address be different in the theFunction?
Thanks for any replies at all.