Thursday, 28 February 2019

How to make a simple class and object in C++

Learn to make a simple class and object in C++


Syntax of creating a class is
:  

  class Classname
{

Code
};

Syntax of creating object of any class is:


Classname  ObjectName ;


 Steps to write the program:-

1. Open a  C++ compiler like Turbo C++  and  write the code given below.

#include<iostream.h>

#include<conio.h>


class Hello            //Creating Class{ public: void show()

{ 

cout<<"Hello EveryOne";

}

};            //Ending Class
void main()

{Hello Obj;  // Here we are creating object of class hello
Obj.show();  // Calling show of class Hello

}




2. Now compile the program and run it.

3. OUTPUT screen will look like this:-









No comments:

Post a Comment

👇 🌐 Top 10 Hosting for Developers in 2025: Fast, Reliable & Affordable

 Whether you’re a beginner building your first portfolio site or a professional developer deploying client projects, choosing the right host...