ra****@op.pl wrote:
class C1
{
int a;
void f();
}
class C2:public C1
{
int b;
void f();
}
class definition must be terminated by a semicolon.
>
Memory:
--------------------------
Data of object C1
int a;
--------------------------
--------------------------
Data of object C2
int b;
--------------------------
where are addresses of methods ?
Short answer: you need to do some research on memory management.
Slightly more elaborate answer:
When the compiler produces a program out of the source containing
classes C1 and C2, it saves the target code of C1::f and C2::f. When
the program is loaded by an operating system this piece of target code
is mapped into a piece of memory called static memory.
Only when the program instantiate an object of either C1 or C2, the
internal data C1::a and C2::a will be stored in memory. If the object is
global, namespace, static, then it will be put in the static memory. If
the object is a local object, it will be stored in the program stack.
Regards,
Ben