DEFINITION 3: CLASS - PRATMG/2143-OOP-Tamang GitHub Wiki

In C++, a class is the fundamental building block that leads to Object-Oriented programming. It is a user-defined data type with its own set of data members and member functions that can be accessed and used by creating an instance of that class. A C++ class is similar to an object's blueprint.

A class in C++ contains, following properties;

  • Data Member
  • Method
  • Constructor
  • Block
  • Class and Interface

CLASS

#include<iostream.h>
#include<conio.h>

class Employee
{
public:
int salary  // data member
void sal()
{
  cout<<"Enter salary: ";
  cin>>salary;
  cout<<"Salary: "<<salary;
}
};
 void main()
 {
  clrscr();
  Employee e; //creating an object of Employee
  e.sal();
  getch();
 }  

My reference:

⚠️ **GitHub.com Fallback** ⚠️