what is the size of an empty class
Answers were Sorted based on User's Feedback
Answer / som shekhar
1 byte.
Reason being when compiler sees an empty class then then it
assigns a 1 byte memory, since the compiler sees the
declaration of the class so he needs to assign some space in
the memory, and hence assign 1 byte memory to hold the
address of the class.
| Is This Answer Correct ? | 4 Yes | 1 No |
Answer / asdf
According to the standard C++03, all classes "shall have
nonzero size."
1 byte is the most common implementation but it is left up
to the vendor.
| Is This Answer Correct ? | 2 Yes | 0 No |
Answer / ankit sharma
size of empty class is 1 byte.
if object does not point to any resource.
it shows object is null but object also get some space in
memory by default either it is empty or not.
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / ansari razi
1 Byte,
when compiling the program compiler allocates 1 byte memory.
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / kaush
1 byte for empty class before assigning the value
| Is This Answer Correct ? | 0 Yes | 1 No |
How is exception handling carried out in c++?
#include <stdio.h> #include <alloc.h> #include <stdlib.h> #include <conio.h> void insert(struct btreenode **, int); void inorder(struct btreenode *); struct btreenode { struct btreenode *leftchild; struct btreenode *rightchild; int data; }; main() { struct btreenode *bt; bt=(struct btreenode *)NULL; int req,i=1,num; clrscr(); printf("Enter number of nodes"); scanf("%d",&req); while(i<=req) { printf("Enter element"); scanf("%d",&num); insert(&bt,num); i++; } inorder(bt); } void insert(struct btreenode **sr, int num) { if(*sr==NULL) { *sr=(struct btreenode *)malloc (sizeof(struct btreenode)); (*sr)->leftchild=(struct btreenode *)NULL; (*sr)->rightchild=(struct btreenode *)NULL; (*sr)->data=num; return; } else { if(num < (*sr)->data) insert(&(*sr)->leftchild,num); else insert(&(*sr)->rightchild,num); } return; } void inorder(struct btreenode *sr) { if(sr!=(struct btreenode *)NULL) { inorder(sr->leftchild); printf("\n %d",sr->data); inorder(sr->rightchild); } else return; } please Modify the given program and add two methods for post order and pre order traversals.
What is memory leak and memory corruption?
What is OOPS and How it is different from Procedural Programming ?
23 Answers HP, Infosys, Thyrocare,
What is the Advantage of Interface over the Inheritance in OOPS?
suppose A is a base class and B is the derved class. Both have a method foo which is defined as a virtual method in the base class. You have a pointer of classs B and you typecast it to A. Now when you call pointer->foo, which method gets called? The next part of the question is, how does the compiler know which method to call?
What is virtual Function.
Why is it so that we can have virtual constructors but we cannot have virtual destructors?
What is interface in oop?
What is the default size allocated for array in the statement if size not specified " int a[] "
What is data binding?
what type of questions