Computer Science, asked by salfara9408, 1 year ago

How to create class in C++

Answers

Answered by vidit05gupta
0

Explanation:

Syntax to create a class in C++

class Class_name

{

   // variables and functions

}

Syntax to create an object in C++

void main()

{

   Class_name object_name;

}

Example:

#include <iostream>

// creating the class

class SuperClass

{

   void display() // member function

       cout << "This is a class";

}

void main()

{

   SuperClass obj; // object declared

   // accessing the member function through an object

   obj.display();

}

Similar questions