| Previous | Table of Contents | Next |
C++ is a language. DOS, Windows, UNIX, and MacOS are operating systems. When you learn C++ youll want to learn it as a portable language without regard to which machine and operating system youll run your programs on.
![]() | Teach Yourself C++ in 24 Hours makes no assumptions about your operating system. This book teaches ANSI C++. ANSI C++ is just another way of saying standard C++the internationally agreed-upon version that is portable to any platform and any development environment. |
Therefore, you wont see anything in this book about windows, list boxes, graphics, and so forth. All that is operating system dependent. Youll see output accomplished through standard output.
To make this work, youll need to tell your compiler to create a console application. Some compilers, written to be used with Windows or the Mac or another windowing environment, call this a quick window, or a simple window, or perhaps a console window.
Your compiler can have its own built-in text editor, or you can use a commercial text editor or word processor that can produce text files. The important thing is that whatever you write your program in, it must save simple, plain-text files with no word processing commands embedded in the text. Examples of safe editors include the Windows Notepad, the DOS Edit command, Brief, Epsilon, EMACS, and vi. Many commercial word processors, such as WordPerfect, Word, and dozens of others, also offer a method for saving simple text files.
The files you create with your editor are called source files, and for C++ they typically are named with the extension .cpp, .cp, or .c. In this book, all the source code files are named with the .cpp extension, but check your compiler for what it needs.
![]() |
|
| Do | Dont |
|---|
| DO use a simple text editor to create your source code, or use the built-in editor that comes with your compiler. | DONT use a word processor that saves special formatting characters. If you do use a word processor, save the file as ASCII Text. |
| DO save your files with the .c, .cp, or .cpp extension. | |
| DO check your documentation for specifics about your compiler and linker to ensure that you know how to compile and link your programs. |
Although the source code in your file is somewhat cryptic, and anyone who doesnt know C++ will struggle to understand what it is for, it is still in what we call human-readable form. Your source code file is not a program, and it cant be executed, or run, as a program can.
![]() |
|
Most modern compilers provide an integrated development environment. In such an environment, you typically choose Build or Compile from a menu, or there can be a function key you press to build your application. Again, youll want to check the documentation for your particular compiler.
After your source code is compiled, an object file is produced. This file is often named with the extension .obj. This is still not an executable program, however. To turn this into an executable program, you must run your linker.
C++ programs are typically created by linking together one or more OBJ files with one or more libraries. A library is a collection of linkable files that you created, were supplied with your compiler, or that you purchased separately. All C++ compilers come with a library of useful functions (or procedures) and classes that you can include in your program. A function is a block of code that performs a service, such as adding two numbers or printing to the screen. A class is a collection of data and related functions; Ill be talking about classes a lot.
The steps to create an executable file are:
| Previous | Table of Contents | Next |