Learn to make a simple class and object in C++
Syntax of creating a class is:
class Classname
{
Code
};
Classname ObjectName ;
{
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
No comments:
Post a Comment