C++ Programming Language: Simple, Short, andStraightforward Way of Learning C++ Programming
Copyright 2016 - KDP Edition Sherwyn Allibang Edition License Notes This book is authorized for your own personal use.This book may not be re-sold or offered away to other individuals.Much thanks to you for regarding the diligent work of theauthor. Introduction This book is for absolute beginners with or withoutprior knowledge in programming, as this book uses
Simplewords,
Short sentences, and
Straightforwardparagraphs. The triple
S way of learning C++ programming.C++ (pronounced as cee plus plus) is a general-purpose programminglanguage. The main object of C++ is to add object-orientation toits predecessor C language. C++ has imperative, object-oriented andgeneric programming features, while also providing facilities forlow-level memory manipulation. There are also other useful featuresadded to C++ such as inheritance and polymorphism.
The topicscovered in this book includes brief introduction to C++programming, variables, data types, control structures, functions,pointers, and file management of external files. This book startsits discussion from short history to installation of the neededsoftware resource and a step by step screen shots of how to writeC++ programming code, compile and execute C++ programs. It presentsgraphical representation of algorithms for simpler learning. Thisbook is packed with working and running C++ program samples andafter reading this book, the reader would be able to develop andcreate C++ language programs based particularly from problems givenin computer science courses, hence, adopting to other programminglanguage will be a lot easier. This book is your initial step inyour programming career. TO GOD BE ALL THE GLORY! The resources used in this book are: > Personal Computer running Windows 7Operating System > Dev-C++ available at http://bloodshed.net Other Operating Systems can also be used andyou may also ought to use other C++ compilers or IDE. NOTE: All links provided in this bookare updated occasionally.
If a link becomes unavailable, email meat zherwyndbest@facebook.com Table of Contents Brief history of C++ Reasons to use C++ Beginning to Program in C++ Language Installing the Dev-C++ for Windows Installing compiler for Linux Self-assessment questions Definition of programming terms The components of a C++ program Writing, compiling, and running our firstprogram using Dev-C++ for Windows Correcting errors Writing, compiling, and running our firstprogram with Linux Compiling and running the program onLinux Statements Null Statements White spaces Self-assessment questions Variable Variable Declaration and definition Scope of variables Constants Keywords typedef declarations Self-assessment questions Displaying text on-screen Accepting user input Self-assessment questions Array Single-Dimensional Multi-Dimensional Array The C-Style Character String Declaring and defining a string Defining a string using input functions C Strings' pre-defined functions in C++ Self-assessment questions Expressions Operators Assignment Operator Mathematical Operators Binary Unary Mathematical operators precedence level andparentheses Relational Operators Logical Operators Type Casting Pre-defined Mathematical Functions Self-assessment questions The if() statement Single-alternative Dual-alternative Multiple-alternative Nested if() statement The switch() statement Things to consider in conditionalstatement: Self-assessment questions What is a Loop? Counter-controlled loop Nested for() loop statement Condition-controlled loop Pre-test loop Post-test loop The Infinite Loop Self-assessment questions User-defined function User-defined function prototype User-defined function definition Calling a user-defined function Things to consider in functions Self-assessment questions Structures Declaring a structure Defining a structure Accessing Structure Members Compound declaration and definition ofstructure Self-assessment questions What is a class? Creating New Types Classes and Members Declaring of a Class in C++ Definition of a Class member method(s) inC++ Defining an Object of a class Accessing Class Members Private versus public access controls Constructor and destructor Self-assessment questions What is exceptions? How Exceptions Are Used The basic steps in using exceptions Self-assessment questions Pointers in C++ Pointer Declaration How pointers works? Pointer Arithmetic Self-assessment questions C++ Files and Streams Opening a File Closing a File Writing to a File Reading from a File Self-assessment questions Acknowledgements The author wishes to express his heartfeltgratitude to the Almighty God for His grace, wisdom, and guidanceand for giving the author the determination to write this book.This book would not have been possible without the support and helpof several individuals who in one way or another contributed andextended their valuable assistance in the preparation andcompletion of this material. The author offer his regards andblessings to all of those who supported him in any respect duringthe completion of this book. Dedication Theauthor dedicates this book to the ALMIGHTY GOD. This book is also dedicated to DennisRitchie for giving the author the tools to program and toBill Gates for giving the author the reasons to program. Chapter1 - Starting C++ Language Programming This chapter presents a brief overview of C++programming. C++ was designed with a basis toward systemprogramming with high performance, efficiency and flexibility ofuse as its design highlights.
This chapter presents the thingsneeded in starting C++ programming. Brief history of C++ The C++ programming language has a historypath in 1979. Bjarne Stroustrup, a Danish computerscientist, is working with the language called "Simula", which is alanguage principally intended for simulations. The Simula 67language underpins object-oriented programming paradigm. Stroustupstarted working with "C" with classes. C isconsidered as middle-level language which has the power ofLow-level language but has high-level language features and C isconsidered as the predecessor of C++.
Bjarne Stroustrup, at BellLabs designed C++ in the early 80s, as an object oriented languagebased on the C language, which powered pretty much all systemssoftware since its creation in 1972. The first C with Classescompiler was called Cfront, which was derived from a C compilercalled CPre. C++'s goal is to add object-oriented programming intoC language. The ++ operator in the C language is an operator forincrementing a variable, which gives some insight into howStroustrup regarded the language. In 1985, Stroustrup's referenceto the language entitled "The C++ Programming Language" waspublished. Reasons to use C++ To start with, C++ is highly recommended forbeginning programmers in starting their programming career becauseC++ covers both procedural and object-oriented programmingapproach.
Once someone learned the concepts behind programminglanguage with C++, adopting or migrating to other programminglanguage will be a lot easier whether it's object-oriented orprocedural-oriented programming, as most of the things needed arepretty similar. C++ has been around a while and it hassolved several industry challenges considering that it is also theprimary language that drives the mobile experience today. Inaddition to high performance server and middleware, C++ is a greatchoice for client side development on the two most popular mobileplatforms Android and iOS and the two most popular desktopplatforms, Windows and Mac OS X. With the recent introduction ofdeveloper tools that enable, among other things, visual design forclients, middleware, and server side apps; C++ is extremelyproductive and really makes it a great choice for modern appdevelopment, so learning the basics of C++ will make someone becompetitive in the industry's stiff competition. This book will bring the world of C++programming closer to you. Beginning to Program in C++ Language All the C++ programs are written into textfiles with extension ".cpp" for example "hello.cpp", where ".cpp"is the extension file name.