Computer Science, asked by gurpreetduggal98763, 11 months ago

write the difference between structure and class with example.​

Answers

Answered by choclaty816
1

Answer:

A class has all members private by default. A struct is a class where members are public by default. Classes allow to perform cleanup (garbage collector) before object is deallocated because garbage collector works on heap memory. Objects are usually deallocated when instance is no longer referenced by other code

Answered by AskewTronics
0

The difference between the class and the structure is as follows:

Explanation:

  • Structure: The structure is a user-defined data type which holds the collection of data member used to hold the value. The data member can hold different types of data. It means that the structure can hold the variable which has from different background.
  • Example of structure in c language: struct ABC { int a; int b;};
  • Class: Class is also a user-defined data type but it holds the collection of function, data members and the other classes of any type.
  • Example of class : class abc {int a=5; void fun(){}}

Learn More:

  • Class and structure : https://brainly.in/question/314797

Similar questions