W
wschlanger
Hi, the following code works as expected, e.g. it prints 1234. How can
this be if the address of C2::x is 0 or 1?? Why does the printf that
prints the address of C2::x, print a 0 or 1 instead of its real
address? What am I missing here?
Thanks in advance,
Willow
--
#include <stdio.h>
class C2
{
public:
int x;
};
class C1 :
public C2
{
public:
void f()
{
C2::x = 0x1234;
printf("%x\n", C2::x);
//The following line prints 0 or 1
printf("%x\n", &C2::x);
//The following line will not even compile. WHY???
//printf("%x\n", (unsigned)(&C2::x));
}
};
int main()
{
C1 a;
a.f();
return 0;
}
---
this be if the address of C2::x is 0 or 1?? Why does the printf that
prints the address of C2::x, print a 0 or 1 instead of its real
address? What am I missing here?
Thanks in advance,
Willow
--
#include <stdio.h>
class C2
{
public:
int x;
};
class C1 :
public C2
{
public:
void f()
{
C2::x = 0x1234;
printf("%x\n", C2::x);
//The following line prints 0 or 1
printf("%x\n", &C2::x);
//The following line will not even compile. WHY???
//printf("%x\n", (unsigned)(&C2::x));
}
};
int main()
{
C1 a;
a.f();
return 0;
}
---