Wednesday, November 15, 2023

Class Introduction

Classes are the central feature of C++ that supports object-oriented programming and are often called user-defined types. 

A class is a basic mechanism to provide “Data encapsulation”. Data encapsulation is an important feature of object-oriented programming.

Syntactically classes are similar to structures. Basic difference between a structure and class is that by default, members of class are private, while members of a structure are public.

  • A class is the collection of related data and function under a single name.
  • Class is an encapsulation of data and functions.
  • Class is an extension of a structure 
  • A class is a collection of data members and member functions.
  • Variables declared in class are called Data Members (Attributes).
  • Functions declared or defined in class are called Member Functions.
  •  A class variable is called object or instance. In other words, a class would be the data type, and an object would be the variable.

Class Declaration:

A class is the blue print or model for a data type because a class constructs a user-defined data type.

A class declaration starts with the keyword class followed by the class name; and the class body, enclosed by a pair of curly braces and terminated by semicolon at the end in similar way as structure.


Data and functions are grouped under two sections private and public. They are also called visibility labels or access specifiers.

0 comments:

Post a Comment

Data Structures with C++



NET/SET/CS PG



Operating Systems



Computer Networks



JAVA



Design and Analysis of Algorithms



Programming in C++

Top