How size of a class can be calulated?

Answers were Sorted based on User's Feedback



How size of a class can be calulated?..

Answer / spoorthi.hebbar

THE SIZE OF THE ATTRIBUTES OF CLASS IS THE ANSWER..

EG.
CLASS DEMO
{
INT A; //IT IS 4 BYTES LONG
INT B; //IT IS 4 BYTES LONG
}
THE TOTAL SIZE IS 8 BYTES.

Is This Answer Correct ?    8 Yes 2 No

How size of a class can be calulated?..

Answer / shweta iyer

Size of a class can be calculated by adding up the size of all its data members.

For example:
class student
{
char name[20]; -----> 4*20=80
int rollno[5]; -----> 2*5=10
......
}

So size of class student is 80+10=90.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C++ General Interview Questions

How do pointers work?

0 Answers  


Can you be bale to identify between straight- through and cross- over cable wiring? And in what case do you use straight- through and cross-over?

0 Answers  


How to stop conversions among objects?

5 Answers   Symphony,


What does override mean in c++?

0 Answers  


How can we read/write Structures from/to data files?

0 Answers  






To what does “event-driven” refer?

0 Answers  


When is the copy constructor called?

0 Answers  


What are the differences between a struct and a class in C++?

7 Answers   Amazon, Wipro,


Difference between a copy constructor and an assignment operator.

0 Answers  


Can we distribute function templates and class templates in object libraries?

0 Answers  


How do you flush a buffer in c++?

0 Answers  


Does c++ have string data type?

0 Answers  


Categories