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 |
What is static in oop?
what's the basic's in dot net
What is ambiguity in inheritance?
What is polymorphism oop?
what is difference between c++ language and java language
char* ptr = "Rahul"; *ptr++; printf("%s",ptr); What will be the output
What are the advantanges of modularity
Question In a class, there is a reference or pointer of an object of another class embedded, and the memory is either allocated or assigned to the new object created for this class. In the constructor, parameters are passed to initialize the data members and the embedded object reference to get inialized. What measures or design change should be advised for proper destruction and avioding memory leaks, getting pointers dangling for the embedded object memory allocation? Please suggest. Question Submitted By :: Sunil Kumar I also faced this Question!! Rank Answer Posted By Re: In a class, there is a reference or pointer of an object of another class embedded, and the memory is either allocated or assigned to the new object created for this class. In the constructor, parameters are passed to initialize the data members and the embedded object reference to get inialized. What measures or design change should be advised for proper destruction and avioding memory leaks, getting pointers dangling for the embedded object memory allocation? Please suggest. Answer # 1 use copy constructors 0 Shanthila There is something to be taken care in destructor, in copy constructor, suppose the memory is assigned to the embedded member object pointer with the parameter passed value, but if some other objects of different class also are pointing to this memory, then if some one deletes the object then this class member pointer object will become dangling, or if the object is not deleted properly then there will be memory leak. Please suggest the design change required to handle or avoid this situation
What is the difference between a constructor and a destructor?
Can main method override?
How to reverse a sentence in c program ex: ram is a good boy answer: boy good a is ram
Why is there no multiple inheritance?