E
E
Evgeny Nikitin2015-11-30 04:19:30
C++ / C#
Evgeny Nikitin, 2015-11-30 04:19:30

How are class descriptions stored in memory?

I understand how objects are stored in memory, but how is the description of classes stored? And is it stored at all? If yes, in what form? (The answer in the form of zeros and ones, as you understand, will not suit you :)) If you can, advise some book or video tutorials on the topic.
PS If this is correct, please explain using these two classes as an example:

class A{
    int *n;
    int* GetN() { return n; }
};

class B : public A {
    char *ch;
    char* GetCh() { return ch; }
};

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Armenian Radio, 2015-11-30
@eunikitin

Classes in C++ exist until the program is compiled.
In a compiled program, only a table of virtual functions can remain from a class, and it is not a fact that the compiler will not throw out virtual calls, replacing them with real ones.

V
Vladimir Martyanov, 2015-11-30
@vilgeforce

Compile your program, load the debug version into IDA and watch. As correctly noted above, different compilers can add this information in different ways.

O
Oleg Tsilyurik, 2015-11-30
@Olej

But how is the description of the classes stored? And is it stored at all?

Not stored... as, however, in the vast majority of compiled languages.
In your example, objects of class A will simply be implemented (embedded) in all objects of class B.
If it's any consolation, you can add that built-in objects of class A will be placed at the beginning of class B objects ... but this knowledge does not add much.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question