TECHGRAVE

Monday, April 17, 2006

How the Object/Classes are compiled?

How the Object/Classes are compiled?

To be specific, how are classes represented in binary code?
This is a very interesting question. In c++ an object or a structure is simply a block of memory that is equal to the sum of sizes of itsmembers in the simple case.
So
class CTest
{
public: int a;
void set(int v){a=v}
}


Could be boken down to an amlost equivalent c representation :
Struct CTest
{
int a;
}

void set(int v, Ctest * this)
{ this->a = v }

Don't take it at face value as such but this is almost what it means.

0 Comments:

Post a Comment

<< Home