+ 8

Difference between Class and structure?

4th Oct 2017, 7:54 PM
Chandrakant More
Chandrakant More - avatar
6 Respostas
+ 7
Thanks Chandrakant More for following me !!!
9th Oct 2017, 4:53 PM
Mattéo
+ 5
C++: A struct's members default visibility is public (classes are private). Java doesn't have structs.
4th Oct 2017, 8:20 PM
Norbivar
Norbivar - avatar
+ 2
Class Class is a reference type and its object is created on the heap memory.  Class can inherit the another class.  Class can have the all types of constructor and destructor.  The member variable of class can be initialized directly.  class object can not be created without using the new keyword, it means we have to use it. Structure Structure is a value type that is why its object is created on the stack memory.  Structure does not support the inheritance.  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 of structure can not be initialized directly.  Structure object can be created without using the new keyword.(optional)
13th Oct 2017, 9:39 AM
Ravish kumar singh
Ravish kumar singh - avatar
+ 1
structure with single data storage,bt with class multiple data store is possible...this is main difference...later u have many differencess....
12th Oct 2017, 5:45 AM
sanjeev
sanjeev - avatar
+ 1
it depends from language. If structure supports function pointers and some other abilities, it's possible to realize inheritance and other propities of class. But it is so complicate and artificially, especially since this language also has a classes, most likely. So, I think, difference in the purpose of existence. Sorry for my english, pianist plays as he can
2nd Nov 2017, 6:14 PM
George Bogatyr
George Bogatyr - avatar
- 1
class itself a structure,in any languages,with multiple times of use...
2nd Nov 2017, 11:01 PM
sanjeev
sanjeev - avatar