Technical Discussion :: C++
Home > Technical Interview Q&A > C++ > Discussion
71 / 187
What is the difference between class and structure?
Answer:
Structure: Initially (in C) a structure was used to bundle different type of data types together to perform a particular functionality. But C++ extended the structure to contain functions also. The major difference is that all declarations inside a structure are by default public.
Class: Class is a successor of Structure. By default all the members inside the class are private.
Asked In ::
Amit Yadav
23 Feb, 2019 5:07 AM
Structure: Initially (in C) a structure was used to bundle different type of data types together to perform a particular functionality. But C++ extended the structure to contain functions also. The major difference is that all declarations inside a structure are by default public.
Class: Class is a successor of Structure. By default all the members inside the class are private.
Class: Class is a successor of Structure. By default all the members inside the class are private.