State true or false for the difference between classes and structures
Answers
What is the difference between class and
Deploy your Django project - free $100/60-day credit.
Spin up a cloud server for Django in 55 seconds with firewalls, monitoring and alerts included.
Learn More
8 ANSWERS
Gopi Chandar
Gopi Chandar, Passionate about Software development
Answered Jun 2, 2016
Class
Class is a reference type and its object is created on Heap memory.
Class can inherit the another class.
Class can have constructor and destructor of all types.
The member variable can be initialized directly.
Class object cannot be created without using the new keyword, it means we have to use it. Eg: Demo obj=new Demo();
Structure
Structure is a value type that is why its object is created on Stack memory.
Structure does not support the inheritance and cannot inherit another class.
Structure can only have the parametrized constructor. it means a structure can not have the non-parametrized constructor,default constructor and destructor also.
The member variable cannot be initialized directly.
Structure object can be created without using the new keyword.(optional). Eg: Demo obj