Title | C++ Basics - C++ Programming Tutorial |
---|---|
Author | Anonymous User |
Course | Introduction to programming /c++ |
Institution | Virtual University of Pakistan |
Pages | 50 |
File Size | 1.6 MB |
File Type | |
Total Downloads | 661 |
Total Views | 927 |
TABLE OF CONTENTS (HIDE)yet another insignificant programming notes... | HOMEC++ Programming LanguageBasicsThis chapter explains the features, technical details and syntaxes of the C++ programming language. I assume that youcould write some simple programs. Otherwise, read &a...
yet another insignificant programming notes... | HOME
TABLE OF CONTENTS (HIDE) 1.Introduction to C++
C++ Programming Language Basics
2.Basic Syntaxes 2.1Revision 2.2Comments 2.3Statements and Blocks 2.4White Spaces and Formatting 2.5Preprocessor Directives
3.Variables and Types This chapter explains the features, technical details and syntaxes of the C++ programming language. I assume that you could write some simple programs. Otherwise, read "Introduction To C++ Programming for Novices and First-time Programmers". To be a proficient programmer, you need to master two things: (1) the syntax of the programming language, and (2) the core libraries (i.e., API) associated with the language.
1.Introduction to C++ C++ Standards C++ is standardized as ISO/IEC 14882. Currently, there are two versions: 1. C++98 (ISO/IEC 14882:1998): First standard version of C++. 2. C++03 (ISO/IEC 14882:2003): minor "bug-fix" to C++98 with no change to the language. Commonly refer to as C++98/C++03 or First C++ standard. 3. C++11 (ISO/IEC 14882:2011): Second standard version of C++. Informally called C++0x, as it was expected to finalize in 200x but was not released until 2011. It adds some new features to the language; more significantly, it greatly extends the C++ standard library and standard template library (STL). 4. C++14: Infomally called C++1y, is a small extension to C++11, with bug fixes and small improvement. 5. C++17: informally called C++1z. 6. C++2a: the next planned standard in 2020.
C++ Features 1. C++ is C. C++ supports (almost) all the features of C. Like C, C++ allows programmers to manage the memory directly, so as to develop efficient programs. 2. C++ is OO. C++ enhances the procedural-oriented C language with the object-oriented extension. The OO extension facilitates design, reuse and maintenance for complex software. 3. Template C++. C++ introduces generic programming, via the so-called template. You can apply the same algorithm to different data types. 4. STL. C++ provides a huge set of reusable standard libraries, in particular, the Standard Template Library (STL).
3.1Variables 3.2Identifiers 3.3Variable Declaration 3.4Constants (const) 3.5Expressions 3.6Assignment (=) 3.7Fundamental Types 3.8Literals for Fundamental Types
4.Operations 4.1Arithmetic Operators 4.2Arithmetic Expressions 4.3Mixed-Type Operations 4.4Overflow/UnderFlow 4.5Compound Assignment Opera 4.6Increment/Decrement Operato 4.7Implicit Type-Conversion vs. Ex 4.8Relational and Logical Operato
5.Flow Control 5.1Sequential Flow Control 5.2Conditional (Decision) Flow Co 5.3Loop Flow Control 5.4Interrupting Loop Flow - "bre 5.5Terminating Program 5.6Nested Loops 5.7Some Issues in Flow Control 5.8Exercises
6.Writing Correct and Good Progr 7.Strings 7.1String Declaration and Initializ 7.2String Input/Output 7.3String Operations 7.4Exercises
8.Formatting Input/Output using 8.1Output Formatting
C++ Strength and Pi tfall C++ is a powerful language for high-performance applications, including writing operating systems and their subsystems, games and animation. C++ is also a complex and difficult programming language, which is really not meant for dummies. For example, to effectively use the C++ Standard Template Library (STL), you need to understand these difficult concepts: pointers, references, operator overloading and template, on top of the object-oriented programming concepts such as classes and objects, inheritance and polymorphism; and the traditional constructs such as decision and loop. C++ is performance centric. The C++ compiler does not issue warning/error message for many obvious programming mistakes, undefined and unspecified behaviors, such as array index out of range, using an uninitialized variable, etc, due to the focus on performance and efficiency rather than the ease of use - it assumes that those who choose to program in C++ are not dummies.
2.Basic Syntaxes 2.1Revision
8.2Input Formatting 8.3Exercises
9.Arrays 9.1Array Declaration and Usage 9.2Array and Loop 9.3Range-based for loop (C++11 9.4Multi-Dimensional Array 9.5Array of Characters - C-String 9.6Exercises
10.Functions 10.1Why Functions? 10.2Using Functions 10.3Default Arguments 10.4Function Overloading 10.5Functions and Arrays 10 6 Pass by Value vs Pass by Re
Below is a simple C++ program that illustrates the important programming constructs (sequential flow, while-loop, and if-else) and input/output. Read "Introduction To C++ Programming for Novices and First-time Programmers" if you need help in understanding this program.
10.7const Function Parameters 10.8Pass-by-Reference via "Refere 10.9Mathematical Functions (Hea 10.10Generating Random Numbe 10.11Exercises
11.File Input/Output (Header upperbound; // Use a while-loop to repeatedly add 1, 2, 3,..., to the upperbound int number = 1; while (number sumEven) { absDiff = sumOdd - sumEven; } else { absDiff = sumEven - sumOdd; } // Print the cout...