Click here to Skip to main content
15,888,189 members
Articles / Containers / Virtual Machine

Skills and Concepts to Program in C++

Rate me:
Please Sign up or sign in to vote.
1.26/5 (31 votes)
7 May 2003CPOL2 min read 50.5K   14   4
Learn the Skills and Concepts to Program in C++ for Beginner & Intermediate/step by step

Day 1: Getting Started

Today You Will Learn

  • Why C++ is the emerging standard in software development
  • The step to develop a C++ program
  • How to enter, compile, and link your first working C++ program

A Brief History of C++

Computer languages have undergone dramatic evolution since the first electronic computers were built to assist in artillery trajectory calculations during World War II. Early on, programmers worked with the most primitive computer instructions: machine language. These instructions were represented by long strings of one and zeros, assemblers were invented to map machine instructions to human-readable and -manageable mnemonics, such as ADD and MOV. In time, higher-level languages evolved, such as BASIC and COBOL. Some languages, such as Microsoft Visual Basic, call the interpreter the runtime library. Java calls its runtime interpreter a Virtual Machine (VM), but in this case VM is provided by the browser (Such as Internet Explorer or Netscape). C++ calls interpreter translates a program as it reads it, turning the program instructions, or code, directly into actions. A compiler translates the code into intermediary form. This step is called compiling, and it produces an object file. The compiler then invokes a linker, which turns the object file into an executable program.

Solving Problems

The problems programmers are asked to solve today are totally different from the problems that programmers were solving twenty years ago. In the 1980s, programs were created to manage large amounts of raw data. The people writing the code and the people using the program were all computer professionals. Today, computers are in use by far more people, and most know very little about how computers and programs work.

Your First C++ Program : "Hello World"

Traditional programming begins by writing the words "Hello World" to the screen, or a variation on that statement.

Building the Hello World Project

To create and test the Hello World program, follow these steps:

  1. Start the compiler.
  2. Choose File, New from the menus.
  3. Choose Win32 Console Application and enter a project name, such as Example 1, and click OK.
  4. Choose An Empty Project from the menu of choices and click OK.
  5. Choose File, New from the menus.
  6. Choose C++ source file and name it ex1.
  7. Enter the code as showing "Listing 1.1".
  8. Choose Build, Build Example1.exe.
  9. Check that you have no build errors.
  10. Press Control+F5 to run the program.
  11. Press the Spacebar to end the program.

Note: As you prepare for your first C++ program, you will need a few things: a compiler, an editor such as Microsoft Visual C++.

C#
//Listing 1.1
#include <iostream>

int main()
{
       std::cout << "Hello World!\n";
       return 0;
}

History

  • 8th May, 2003: Initial post

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralRe: Could be better Pin
Nader Omar9-May-03 11:12
Nader Omar9-May-03 11:12 
GeneralCould be better Pin
Ian Darling8-May-03 22:49
Ian Darling8-May-03 22:49 
Apologies for rating as poor, but I feel this article would benefit from some major work (10/10 for concept, minus several million for implementation Smile | :)

a) The brief history of C++ doesn't actually cover C++ at all. Where is the detail on CFront, Stroustrup's reasoning behind developing the language, and what problems it was designed to solve, and how each langauge construct was developed (all in his book The Design and Evolution of C++, BTW)

b) Solving problems - the programming problems today aren't any different - we still write tools that manage a lot of data - databases, media players, office tools, etc. The major problems to solve for todays computing aren't about these problems anymore, but are instead about software usability and ergonomics.

c) "Why C++ is the emerging standard in software development". TBH, I thought it already was a standard in software development, along with VB, Java and COBOL.... But you don't explain this statement at all.

d) Tools. You give the steps to create the relevant project, and only then indicate what you are probably using. This is a bit of a nitpick, but to anyone who isn't familiar with the tools, or using a different set (eg, Borland, or GNU tools), it's hard to follow. I would have placed emphasis on the language itself, and left a discussion of tools to a separate article (Day 2, perhaps?).

e) No explaination of what each line in the example program means. If I was to be learning C++ from this series, then I would find that omission frustrating

I'd like to point out that Koenig and Moo's book Accelerated C++ is an excellent guide for learning C++. Perhaps a series where you extended existing material would be a better way forwards? I think there is some real value in the series' concept, but this article is a let down. Also, the skills a beginner developer needs to learn are very different from an intermediate one, and trying to stuff them into one series as the title suggests, is trying to cram too much in one go.

I hope this criticism helps you turn this article/series into what it deserves to be - an excellent guide for beginners.

--
Ian Darling
GeneralRe: Could be better Pin
Warbit25-Aug-08 0:22
Warbit25-Aug-08 0:22 
GeneralRe: :) Pin
Martyn Pearson9-May-03 1:14
Martyn Pearson9-May-03 1:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.