Where are class methods in memory?
Hello, I'm new to C++ object programming, I've been working for one year with C.
I googled and searched through this forum, but found nothing.
I'm now trying to use some classes in my C application, so I'm having an "adaptation" work: I'm trying to compile the c++ part in an obj, and then using the classes through C functions and structures.
I need to know where are placed in memory the methods of Cpp structures. To be clear:
Code:
struct A_cpp_base
{
int buf[100];
void A_cpp_base( void ){ memset( this , 0 , sizeof( *this ) ) };
void method( void ){......};
........
};
struct A_c_base
{
int buf[100];
};
struct A_cpp : public A_cpp_base
{
int a;
int b;
int d[100];
void A_cpp( void ){ memset( this , 0 , sizeof( *this ) ) };
void method( void ){......};
........
} A_cpp_object;
struct A_c{
A_c_base publicFromACppBaseAdapted;
int a;
int b;
int d[100];
}A_c_object;
How can I copy the members of a A_cpp_object in a A_c_object as fast as possible?
I was thinking about something as:
Code:
memcpy( &A_c_object , &A_cpp_object , sizeof( A_c_object ) )
But I need to know where are placed the public components of the base class of the object that I need to copy.
Thank you for help,
BrownB