Presentation is loading. Please wait.

Presentation is loading. Please wait.

Class and Structure. 2 Structure Declare using the keyword struct purpose is to group data Default visibility mode is public A struct doesn't have a constructor.

Similar presentations


Presentation on theme: "Class and Structure. 2 Structure Declare using the keyword struct purpose is to group data Default visibility mode is public A struct doesn't have a constructor."— Presentation transcript:

1 Class and Structure

2 2 Structure Declare using the keyword struct purpose is to group data Default visibility mode is public A struct doesn't have a constructor or destructor Cannot support overloaded operators. Cannot use C++-specific features such as inheritance and member functions. A structure couldn't be null like a class.

3 3 Class Declare using the keyword class A class should be used for grouping data and methods that operate on that data The class default access type is private Classes have a public and private members The default mode for inheritance is private. classes are used to encapsulate data and the functions Class support constructors and destructors Class support operator overloading & function Overloading Class can be declare al null

4 4 Class Vs Structure Members of a class are private by default and members of struct are public by default class Test { int x; // x is private }; void main() { Test t;// class boject t.x = 20; // compiler error // because x is private } struct Test { int x; // x is public }; void main() { Test t; t.x = 20; // works fine because x is public }


Download ppt "Class and Structure. 2 Structure Declare using the keyword struct purpose is to group data Default visibility mode is public A struct doesn't have a constructor."

Similar presentations


Ads by Google