Sunday, March 25, 2007

Getting Started with C++

What is C++?Released in 1985, C++ is an object-oriented programming language created by Bjarne Stroustrup. C++ maintains almost all aspects of the C language, while simplifying memory management and adding several features - including a new datatype known as a class (you will learn more about these later) - to allow object-oriented programming. C++ maintains the features of C which allowed for low-level memory access but also gives the programmer new tools to simplify memory management.
What is C++ used for?C++ is a powerful general-purpose programming language. It can be used to create small programs or large applications. It can be used to make CGI scripts or console-only DOS programs. C++ allows you to create programs to do almost anything you need to do. The creator of C++, Bjarne Stroustrup, has put together a partial list of applications written in C++.
What is Object-Oriented Programming?Object oriented programming is essentially building a program around self-contained collections of data and code to modify that data; this programming model is in contrast to a model that uses function that act on data scattered throughout a program. Object-oriented programming (or coding, as programming is commonly referred to) is an organizational style, but it helps programmers create reusable code because the code to do a specific thing is entirely contained within a single section of code, and to use the code to perform tasks - for instance, creating a menu - involves using only a small number of functions to access the internals of the class. Think of it as a black box that can be easily carried from place to place, and that performs complex actions simply at the press of a button: for instance, a microwave lets you heat food for a specified time limit - say, two minutes - by typing in the time and pressing the heat button. You do not need to know how the microwave operates or why the physics works. In the same way that self-contained appliances simplify life for the consumer, object-oriented programming simplifies the transfer of source code from one program to another program by encapsulating it - putting it all in one place.
What do you need to program in C or C++?In order to make usable programs in C or C++, you will need a compiler. A compiler converts source code - the actual instructions typed by the programmer - into an executable file. Numerous compilers are available for C and C++. Listed on the sidebar are several pages with information on specific compilers. For beginners, Bloodshed Dev, which uses a Windows interface, is a free and easy-to-use compiler.
How do you learn C++?No special knowledge is needed to learn C++, and if you are an independent learner, you can probably learn C++ from online tutorials or from books. There are plenty of free tutorials online, including the one on this site - one which requires no prior programming experience. You can also pick out programming books from our recommendations. While reading a tutorial or a book, it is often helpful to type - not copy and paste (even if you can!) - the code into the compiler and run it. Typing it yourself will help you to get used to the typical typing errors that cause problems and it will force you to pay attention to the details of programming syntax. Typing your program will also familiarize you with the general structure of programs and with the use of common commands. After running an example program - and after making certain that you understand how it works - you should experiment with it: play with the program and test your own ideas. By seeing which modifications cause problems and which sections of the code are most important to the function of the program, you should learn quite a bit about programming. New! Try our C++ Beginner to C++ Expert recommended book series, a six-book set designed to get you maximal information and help take you from beginner to C++ master.
Do I need to know C to learn C++?No. C++ is a superset of C; (almost) anything you can do in C, you can do in C++. If you already know C, you will easily adapt to the object-oriented features of C++. If you don't know C, you will have to learn the syntax of C-style languages while learning C++, but you shouldn't have any conceptual difficulties.
What's the point of learning to program? What can I get out of it?Ah, a skeptic! You can get a lot of things out of programming. For one thing, it's just plain fun. You can read my opinion on the matter here: Why Learn to Program?
I want to make games in C++, what should I do?It may be a challenging road, but it is doable. This article has more information: so you want to be a game programmer?
What does it take to learn to be a programmer?Great question! Here's an article about what it takes to be a programmer!
Help me use my compilerGo here to learn how to use a compiler.
How should I think about Program Design?Try Thinking about Programming - A Beginner's Guide
Help, my program doesn't work!Take a look at a list of common programming mistakes, send us an email or, if you're really stuck, join our message board or ask an expert!
Where can I learn more about the history of computer science?Try this article on computer science.

No comments: