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

DBMS NOTES UNIT 3

                                                              UNIT 3  ER (Entity Relationship) An entity-relationship model is known as an E...