if we right like that:

class myClass
{
int a;
string b;
char c;
}

what will be the size of this class?

Recommended Answers

All 2 Replies

Use the built-in function sizeof() to get the size of your class in bytes.

// prints out the size of 'myClass' in number of bytes
cout << sizeof(myClass)

uh, not necessarilly. That will give the size in bytes of a single instance of the class, not the "size of the class" whatever that might be (op never gave any indication what he means by the term).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.