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.
one more difference apart from public and private access specifier, that struct dont have protected as an access specifier while class do.
There are two differences between Structure and Class. Firstly, Structure cannot be inherited. Secondly, Structure is a value data type whereas Class is a reference type.
1) structure instances cannot be used as operand to arithmetic operators like +-*/ . But object (instances of classes) can be (using operator overloading). 2) There is no data hiding features comes with structures. Classes do, private, protected and public
A structure is a convenient tool for handling a logicaly related data items,it is a user defined data type with templet. Example: struct student { char name[20]; int Roll_no; float marks; }; A class is an extention of the idea of stucture used in C.It is a way of creating and implementing a user defined data type Example: class class_name { private: variable declaration; function decleration; public: variable declaration; function decleration; }; A structure do not hav the property of data hiding that is all the members of structure are accessible by any function anywere in there scope.that is the data member of structure are public by default A class have the property of data hiding that is the data member of the class are accessible only by there object,the data member of class are private by default
class:- class is extracted for the fetures of oops sturcture structure the collection of all members of different data types class:- in class we can use all the 3 access specifiers and they are 1.private 2.public 3.protected structure:- we use only private(defult) structure:- structure has a keyword struct class:- class itself is an keyword sturcture:- structure has more security class:- class has a low security when compared to structure structure: we use "->" for accessing class:- in class we use "."
1.By default the members of a structure are public and for a class they are private. 2.A structure can't declare protected members,a class can. 3.A structure can't be abstract, a class can. 4.A structure is a value type, while a class is a reference type.