C++ Hello World Tutorial
This C++ Hello World tutorial is written for beginning C++ students without previous C++ programming experience. ...
using namespace std;
cout << "Hello World!" << endl;
cout << "Welcome to C++ Programming" << endl;
#include <iostream> brings in the needed libraries for console output.
using namespace std; keeps you from having to type std::cout each time that output is needed.
void main() is the main function which executes first, before any other code.
The word void means that the function does not return anything.
cout << is the output statement and strings need quotation marks.
End the cout line with a semicolon. If you use << endl; do not put a semicolon in the middle of the line. The endl; means that the next cout will have a new output line; this ends the line for this cout statement.
Using the Older VC++ 6.0 Compiler
Students with beginning C++ programming knowledge will learn methods, properties and classes all using the "console". To begin a new C++ project, using VC++ 6:
Select File, New. Click on the Projects tab. Click on the Win32 Console Application.
Set the project name and location then click OK. Select the "empty project" radio button.
Now click Finish. (Next dialog box that pops up, just click OK).
Now you will see part of the development environment. Find the top row menu bar and click on Projects. Select "Add to Project", then select "New".
The New dialog box pops up. Click on Files if the File tab is not already active.
With the files tab activated and in front, select the "C++ Source File". Type in a filename then click OK. The flashing cursor will be in a white area and you are ready to begin typing in a C++ console application.
When you have typed in your program, click on the Build menu item in the Working area. Build is on the menu bar. Find the red exclamation mark and click on "execute new_.exe". A window pops up that says "The file does not exist. Do you want to build it?" Select yes. It should link and you should be able to see the console output. If not, you have errors and the lower window will list the errors if you scroll to the top of the lower window of the development environment. Double clicking on an error in the list will point to the code line in question. A pointer shows up near the typed code if you have clicked on an error message. This points to the problem line and the message may not necessarily relate to what the problem really is. Your textbook should have additional information about the compiler you are using in class...if not, please ask your instructor for information about that compiler if it was not provided in the first class session...
Do not attempt to install the VC++ 6 compiler on the XP operating systems. Get a newer Microsoft VC++.NET compiler for the XP operating system.