Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors

Object & Classes

What is class in programming ?

In programming, a class is a blueprint or a template that defines the structure and behavior of objects.

It serves as a reusable programming construct that encapsulates data (member variables) and functions (member functions).

Syntax for defining a class in C++:

class ClassName {
    // Member variables
    // Member functions

What is an object in programming ?

In programming, an object is an instance of a class.

Syntax to creates a class object:

ClassName objectName;

Program to show use of Class and Object in C++:

#include <iostream>
class Papa { // create class Papa
    int age=30; // member variable

    void show() //member function
        cout <<age;

void main() {
    Papa obj; // create object obj;
C++ Output