Home | | Computer Science 11th std | C++: Declaration of a class

Chapter: 11th Computer Science : Chapter 14 : Classes and objects

C++: Declaration of a class

A class is defined in C++ using the keyword class followed by the name of the class.

Declaration of a class

 

A class is defined in C++ using the keyword class followed by the name of the class. The body of the class is defined inside the curly brackets and terminated either by a semicolon or a list of declarations at the end.

The only difference between structure and class is the members of structure are by default public where as it is private in class.

 

The General Form of a class definition

class class-name

{

private:

      variable declaration;

      function declaration;

protected:

      variable declaration;

      function declaration;

public:

      variable declaration;

      function declaration;

};

• The class body contains the declaration of its members (Data member and Member functions).

• The class body has three access specifiers (visibility labels) viz., private , public and protected.

 


Study Material, Lecturing Notes, Assignment, Reference, Wiki description explanation, brief detail
11th Computer Science : Chapter 14 : Classes and objects : C++: Declaration of a class |

Related Topics

11th Computer Science : Chapter 14 : Classes and objects


Privacy Policy, Terms and Conditions, DMCA Policy and Compliant

Copyright © 2018-2023 BrainKart.com; All Rights Reserved. Developed by Therithal info, Chennai.