Tuesday, January 30, 2018

Difference between class and Structure

Objective
class
Structure
Memory
It’s object is created on the heap memory
It’s object is created on the stack memory
Inherit
inherit the another class
Does not support the inheritance
Constructor, Destructor
Class can have the all types of constructor and destructor.
Structure can only have the parameterized constructor. it means a structure can not have the non-parameterized constructor, default constructor and destructor also.
Initialized Variable
class can be initialized directly
structure can not be initialized directly
Type
Reference type
Value type
Object creation
New Keyword
No need

No comments:

Post a Comment