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

What is difference between c++ 11 and c++ 14?

0 Answers  


Explain one-definition rule (odr).

0 Answers  


What is a constant? Explain with an example.

0 Answers  


What is the use of "new" operator?

0 Answers  


Discuss the possibilities related to the termination of a program before entering the mainq method?

0 Answers  






Can we run c program in turbo c++?

0 Answers  


Explain 'this' pointer and what would happen if a pointer is deleted twice?

0 Answers   Genpact,


Define a program that reads two matrices of size 3x3 with real values from the user then prints their sum, difference and multiplication.

0 Answers   TCS,


Write a C/C++ program to show the result of a stored procedure "PROC_RESET_MAIL" on database "USER_NOTIFY".

2 Answers   ABC, Accenture, DataLand, HCL, Webyog,


Differentiate between an array and a list?

0 Answers  


Difference between declaration and definition of a variable.

0 Answers  


What is difference between class and function?

0 Answers  


Categories