Difference between Class and Structure




Distinguish, differentiate, compare and explain what is the difference between Class and Structure. Comparison and Differences.

Differences between Class and Structure

S.No. Class Structure
1 Class is group of common objects that share common properties and relationships. Structure is a collection of different types of data type.
2 Class members are private by default. Structure members are public by default.
3 Classes are reference type i.e. they are stored on heap. Structure are value type i.e. they are stored on stack.
4 Class does require constructor. Structure does not require constructor.
5 Class can be inherited. Structure can not be inherited.
6 Class elements can be declared as protected. Structure elements can not be declared as protected.
7 Class is better choice for complex data structure. Structure should be used when you want to use a small data structure.
8 Classes are terminated i.e. GC does call finalize method for them. Structure are not terminated i.e. GC does not call finalize method for them.

Download PDF

Search More Topics on the Web



Tags:

Difference between Structure vs Class

Class vs Structure

Differences between Structure vs Class

Spreading Knowledge Across the World

USA - United States of America  Canada  United Kingdom  Australia  New Zealand  South America  Brazil  Portugal  Netherland  South Africa  Ethiopia  Zambia  Singapore  Malaysia  India  China  UAE - Saudi Arabia  Qatar  Oman  Kuwait  Bahrain  Dubai  Israil  England  Scotland  Norway  Ireland  Denmark  France  Spain  Poland  and  many more....