------------------------------------------------------------------------------
MC logo
Hello Again, World!
[^] CSc 220 Home
------------------------------------------------------------------------------
[Introduction] [Boolean and Control] [Functions] [Arrays and Pointers] [Dynamic Arrays] [Array Errors] [Command Array] [Standard Containers] [Structs and Classes] [Automatic Pointer] [Multi-File Programs] [Copying Objects] [Templates] [Inheritance] [Plain C I/O] [Type Odds And Ends] [Plain C Strings] [File I/O]
[Standards] [Programming Environment] [Hello, World!] [Hello Again, World!] [Identifiers] [Constants] [Average of Three] [Basic Types] [Shortcut Operators] [Increment Operators] [C++ Strings]
hello2.cpp
#include <iostream>

/*
 * Just another way to do it.
 */
int main()
{
        // Say it now.
        std::cout << "Greetings, local planet!" 
                  << std::endl;

        return 0;
}

This just a couple of different things. In particular, instead of saying using namespace std;, I have used the std:: qualifier on the the names from the libraries. This is essentially the full name: std::cout is cout of the family std, which is the standard C++ library.

I've also put the print across two lines. You probably already figured out that that would work.

The other thing is the return statement from main. In C++, main returns an integer, so it is most correct to have a return statement at the end. There is a long story here which I will avoid right now. For the present:

So usually folks just leave it out.