Site icon T4Tutorials.com

Write a program class name is hello and displays hello world on the screen.

Write a complete program whose class name is hello and that displays hello, world on the screen.
#include<iostream>
using namespace std;
// Creating clas
class hello
{
  public:

    void display() {
      cout << "Hello World";
    }
};
int main()
{
    hello t4tutorials;    // Creating an object
    t4tutorials.display();  // Calling function
    return 0;
}

Output

Hello World

Explanation:

Class: hello

user define function: display

built-in  function: main

object: t4tutorials

Exit mobile version