How to create class in C++
Answers
Answered by
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