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:-








Comments

Popular posts from this blog

Java Project Code: Cinema Ticket booking system : Create a Java Application to book a ticket in a Cinema hall.