VOOZH about

URL: https://www.geeksforgeeks.org/cpp/print-hello-world-empty-blank-main-c/

⇱ Print "Hello World" with empty or blank main in C++ - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Print "Hello World" with empty or blank main in C++

Last Updated : 14 Jun, 2022

Write a program in C++ that prints "Hello World", it has a main function and body of main function is empty.

Following are three different solutions.

  • We can create a global variable and assign it return value of printf() that prints "Hello World" 
  • We can use Constructor in C++. In the below program, we create an object of class 'A' outer of the main Function so object declaration time it will be call to constructor so that it will be print "Hello World". 
  • We can initialize a global variable with return type of function that prints “Hello World”.
Comment
Article Tags:
Article Tags: