+ 2
why the output of this code is 4 why not 5 or 8.
#include<iostream> using namespace std; class A { int a; static int b; }; int A::b; int main() { cout<<sizeof(A); return 0; }
6 Réponses
+ 3
~ swim ~
So the `sizeof` only returns summary of size of instance members (excludes class member) when it comes to objects?
+ 1
Because int is 4 bytes
+ 1
but about static int b
+ 1
Aadarsh Gupta
The static int variable also occupies 4 bytes.