What is the size of class
Answers were Sorted based on User's Feedback
Answer / suresh
Size of an emty class is One Byte. If it has variables the
sum of size of variables If it has Virtual functions
Compiler inserts VPTR. So the size includes VPTR which is 4
bytes
Is This Answer Correct ? | 24 Yes | 2 No |
Answer / mvs ravi kumar
Size of all variables present in a class
Plus
add size of int for each virtual function if present.
If the class is an empty class then its size is one byte.
This is because to differentiate between two different
objects of that class.
Is This Answer Correct ? | 25 Yes | 5 No |
Answer / raghu
#include <iostream.h>
class A
{
};
void main(int argc,char *argv[])
{
A a;
cout << " Size of Class A's object 'a' is = " <<
sizeof(a);
return;
}
Ans: Size of Class A's object 'a' is = 1
Is This Answer Correct ? | 22 Yes | 2 No |
Answer / ratnesh sachan
Size of an object of an empty class is one otherwise the
size of the class is equal to the sum of the size of the
variables of that class. The size of class dose not depend
on the functions of that class.
Is This Answer Correct ? | 7 Yes | 6 No |
Answer / amrit
If class is no member function and member variables its size
will be i byte ,if it have both then size will be addition
of all member variables but when the function is virtual
then it take 4 bytes for it ,if class have more than one
virtual function then size for all the virtual function not
include,it only include first virtual function size which
is 4 bytes.
Is This Answer Correct ? | 4 Yes | 3 No |
Answer / saisumanth.nimmagadda
i think size of the class is 1byte
Is This Answer Correct ? | 1 Yes | 0 No |
The defoult size of an object is one bite.becouse every
object contains a distinct adress.
class a
{
};
main()
{
a obj;
}
Here the size of obj is one bite.
Is This Answer Correct ? | 4 Yes | 5 No |
Answer / preeti
The size of class is equal to size of member variables
present in that class.
EXAMPLE:-
class abc
{
public int x;
};
void main()
{
abc a;
cout<<sizeof(a) ;
}
Is This Answer Correct ? | 1 Yes | 2 No |
Tell me about different kinds of synchranization objects ?
What is document-view architecture ? Give me one real time example for SDI ?
What is the initial function to be called in MFC and what it will do
What is the use of message map ?
how u can move CDC pointer to one line in cview?
What is the difference between Extension DLL and Regular DLL?
Explain Doc/View architecture
What is CALLBACK? How it work? what is the advantage of CALLBACK, please explain with an example
How many types of combo box are their
2 Answers Aaditya Info Solutions, E Logic,
What is LoadLibrary function returns?
What function is used to disable a control at runtime?
what is message loop how mfc does it internally?