+ 1
Why it prints 1
#include<iostream> using namespace std; class a{}; int main() { cout<<sizeof(a); return 0; }
1 Answer
+ 1
Empty structs/classes have a size of 1 so that it can exist in memory. If it had 0 then pointer arithmetic would fall apart.