How size of a class can be calulated?
Answers were Sorted based on User's Feedback
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 |
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 |
Explain RAII (Resource Acquisition Is Initialization).
What are the total number of lines written by you in C/C++? What is the most complicated or valuable program written in C/C++?
Explain public, protected, private in c++?
What is private inheritance?
How can you create a virtual copy constructor?
Which software is best for coding?
What problems might the following macro bring to the application?
what is the size of this class class size { public: char data1; double d; int data2; char data3; double data4; short data5; }; please explain the padding for these double variables.
What is problem with overriding functions?
Differentiate between structure and class in c++.
What is realloc() and free()? What is difference between them?
Is c++ pass by reference or value?