Print Hello world using class and object in C++ by R4R Team

Class:

Here we can take Human Being as a class. A class is a blueprint for any functional entity which defines its properties and its functions. Like Human Being, having body parts, and performing various actions.

Objects:

My name is Abhay, and I am an instance/object of class Male. When we say, Human Being, Male or Female, we just mean a kind, you, your friend, me we are the forms of these classes. We have a physical existence while a class is just a logical definition. We are the objects.


program-

#include
using namespace std;
//Create class
class myclass
{
public:
//data member that print hello world
int display()
{
cout<<"Hello world";
}
};
int main()
{
//create class object
myclass obj;
//call function using object.
obj.display();
return 0;
}


output-

Hello world




Leave a Comment:
Search
Categories
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!