The structure of a C++ Program While C++ as a language has a great deal of flexibility, there are very specific and detailed requirements with which a program must comply. This section introduces the student to the basic of those requirements. Sample program: myfirst.cpp-display "Come up and C++ me some time" * Introduction to C++ output streams * Using functions and how they are structured * The use of main() function * Returning a value from a function * Using arguments in calling a function * Comments and their importance in structured programming C++ preprocessor and its use The preprocessor gives great flexibility to the language and provides a structured way to include the standard features of the language. This section is a brief introduction to the preprocessor, so that the student can begin using its features. * Header files and how they are included * Standard C++ header files * #include C++ Output C++ has many ways to output information, and cout is one of the simplest and most flexible. The student can now begin ti display the results of programs. * Using cout for simple output * Variable conversion using cout * cout and print() * The << insertion operator * |n newline character C++ source code formatting By their nature, programming languages are usually not a direct extension of native spoken language. A simple C++ program, perhaps more than most, can be obfuscated by poor structure. It is time to begin developing good formatting habits. * Lone oriented versus statement oriented languages * ; terminated statements * Introduction to language syntax * C+ coding style conventions Some basic C++ statments Statements in C++ do the rteal work of the program. This section is an introduction to a variety of statements available in the language and how they are constructed. Sample programs: fleas.cpp - "My cat has 28 fleas" yourcat.cpp - input the number of fleas your cat has * Use of variables in c++ * C++ language keywords * Declaration statement to create a variable * Assignment statement * Operator overloading * Input using cin Functions Functions are one type of C++ statement. Here the student learns about how to call functions, both from the standard library and user-defined Sample programs: sqrt.cpp - using the library function sqrt() ourfunc.cpp - user-defined function convert.cpp - convert stones to pounds * Calling conventions, with and without arguments * Return values * Function prototype for every function Prototype: how the function relates to the outside world Function: Black box * Using header files for function prototypes * Standard library functions * User-defined functions * Function header Return value type Name of function Arguments to functions * Function body in braces * All function are created equal Introduction to C++ objects With the foundation laid so far, we now introduce one of the keys of the power of C++; objects. Objects are covered in great detail later, but the student starts an understanding of object-oriented programming * Concepts of classes * Objects - particular instance of a class * Class libraies * Messages to objects * Class methods