Output of C program

#include
#include
using namespace std;


class A{
public:
    int i;
    static int j;
};

int main()
{
    cout << sizeof(A)<< " Bytes";
    _getch();
}


Answer: 4 Bytes
Static data members do not contribute in size of an object. So ‘i’ is not considered in size of Test. Also, all functions (static and non-static both) do not contribute in size.

Comments

Popular Posts