Why is sizeof Derived Class is 8?
c++
Solution
The size is Implementation dependent and it depends on how the particular compiler implementation implements virtualism & padding. You shouldn't expect the value specifically to be something. If you want to calculate the size in your program just use `sizeof` and thats about it.
Problem
``` #include <iostream> using namespace std; class Empty {}; class Derived : virtual public Empty { char c; }; int main() { cout << "sizeof(Empty) " << sizeof(Empty) << endl; cout << "sizeof(Derived) " << sizeof(Derived) << endl; return 0; } ``` Why size is coming 8 I think it should be 9, If I declare 'c' as integer then also its coming 8 Cany you please explain me the logic