Q:

C++ program to create a simple class and object

belongs to collection: C++ Classes and Object programs

0

C++ program to create a simple class and object

In this program you will learn how to create a class, create object of that class and calling the member function in main function.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Simple class and object creating program in C++

/* C++ program to create a simple class and object.*/

#include  <iostream>
using namespace std;
 
class Hello
{
    public:
        void sayHello()
        {
                cout << "Hello World" << endl;
        }
};
 
int main()
{
    Hello h;
     
    h.sayHello();
     
    return 0;
}

Output

Hello World

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

C++ Classes and Object programs

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
C++ | Create an object of a class and access class... >>