Good time of day!
I wrote some code, but I cannot understand some strange memory anomalies. Could anybody, who has a proper knowledge in class memory using give me a explanation?
My code:
#include <iostream>
using namespace std;
class O
{
    O();
    ~O();
};
class A
{
public:
    A();
    ~A();
    void someFunc();
private:
    int m_a;
};
class B: public A
{
public:
    B();
    virtual ~B();
private:
    int m_b;
};
class C: public B
{
public:
    C();
    ~C();
private:
    char m_c;
};
int main()
{
    cout << sizeof(char) << endl;
    cout << sizeof(int) << endl;
    cout << sizeof(O) << endl;
    cout << sizeof(A) << endl;
    cout << sizeof(B) << endl;
    cout << sizeof(C) << endl;
    cin.get();
    return 0;
}
output:
1  //normal for char
4  //normal for int on x32
1  //why empty class occupies 1 byte?
4  //int m_a.  Where is 1 byte?
12 //4B virtual function, 8B - m_a and m_b.
16 //char needs 1 byte. Why it gets 3 more?
Thank you for attention and answers )
 
     
    