Books Available Q4 2017.

The preview is not designed for a mobile device. Please use a laptop/desktop computer.

Understanding C++ Bjarne Stroustrup

  • Bjarne Stroustrup, the designer and original implementer of C++, has reorganized, extended, and completely rewritten his definitive reference and tutorial for programmers who want to use C++ most effectively.
  • Bjarne Stroustrup
  • 12.09.2010
  • 397 pages

Available Q4 2017.

Loved the preview? Share it!

Chapter 1: The Origins of C++

C++ was developed by Bjarne Stroustrup Bjarne Stroustrup is a Danish computer scientist, most notable for the creation and development of the widely used C++ programming language of AT&T Bell Laboratories in the early 1980's, and is based on the C language. The name is a pun - "++" is a syntactic construct used in C (to increment a variable), and C++ is intended as an incremental improvement of C. Most of C is a subset of C++, so that most C programs can be compiled (i.e. converted into a series of low-level instructions that the computer can execute directly) using a C++ compiler.

C is in many ways hard to categorise. Compared to assembly language it is high-level, but it nevertheless includes many low-level facilities to directly manipulate the computer's memory. 20 People
Marked this as important.
It is therefore an excellent language for writing efficient "systems" programs. But for other types of programs, C code can be hard to understand, and C programs can therefore be particularly prone to certain types of error. The extra object-oriented facilities in C++ are partly included to overcome these shortcomings.

Object-Oriented Programming

C++ fully supports object-oriented programming, including the four pillars of object-oriented development:

  1. Encapsulation

  2. Data hiding

  3. Inheritance

  4. Polymorphism

Standard Libraries

The core language giving all the building blocks including variables A variable provides us with named storage that our programs can manipulate. Each variable in C++ has a specific type, which determines the size and layout of the variable's memory. , data types and literals, etc. The C++ Standard Library giving a rich set of functions manipulating files, strings, etc. The Standard Template Library (STL) giving a rich set of methods manipulating data structures, etc.14 People
marked this as important.

Learning C++

The most important thing to do when learning C++ is to focus on concepts and not get lost in language technical details. The purpose of learning a programming language is to become a better programmer; that is, to become more effective at designing and implementing new systems and at maintaining old ones.

Use of C++

C++ is used by hundreds of thousands of programmers in essentially every application domain.

C++ is being highly used to write device driversA device driver is a program that controls a particular type of device that is attached to your computer. There are device drivers for printers, displays, CD-ROM readers, diskette drives, and so on. and other softwares that rely on direct manipulation of hardware under realtime constraints.

C++ is widely used for teaching and research because it is clean enough for successful teaching of basic concepts.

Anyone who has used either an Apple Macintosh or a PC running Windows has indirectly used C++ because the primary user interfaces of these systems are written in C++.

Basic Syntax

When we consider a C++ program, it can be defined as a collection of objects that communicate via invoking each other's methods. Let us now briefly look into what do class, object, methods and Instance variables mean.

C++ Program Structure:

#include <iostream>
using namespace std;
// main() is where program execution begins.
int main()
   cout << "Hello World"; // prints Hello World
   return 0;

Let us look various parts of the above program:

Compile & Execute C++ Program:

Let's look at how to save the file, compile and run the program. Please follow the steps given below:

  • Open a text editor and add the code as above.

  • Save the file as: hello.cpp

  • Open a command prompt and go to the directory where you saved the file and run.

Data Types

Primitive Built-in Types:

C++ offer the programmer a rich assortment of built-in as well as user defined data types. Following table lists down seven basic C++ data types:Supriya
marked this as important

Type Keyword
Boolean bool
Character char
Integer int
Floating point float
Double floating point double
Valueless void
Wide character wchar_t

Several of the basic types can be modified using one or more of these type modifiers:

The next table shows the variable type, how much memory it takes to store the value in memory, and what is maximum and minimum value which can be stored.

Type Typical Bit Width Typical Range
char 1byte -127 to 127 or 0 to 255
unsigned char 1byte 0 to 255
signed char 1byte -127 to 127
int 4bytes -2147483648 to 2147483647
unsigned int 4bytes 0 to 4294967295
signed int 4bytes -2147483648 to 2147483647
short int 2bytes -32768 to 32767
unsigned short int Range 0 to 65,535
signed short int Range -32768 to 32767
long int 4bytes -2,147,483,648 to 2,147,483,647

Following is the example, which will produce correct size of various data types on your computer.Hey! I believe this is an important example. This may come in our exam. - Supriya

#include <iostream>
using namespace std;

int main()
   cout << "Size of char : " << sizeof(char) << endl;
   cout << "Size of int : " << sizeof(int) << endl;
   cout << "Size of short int : " << sizeof(short int) << endl;
   cout << "Size of long int : " << sizeof(long int) << endl;
   cout << "Size of float : " << sizeof(float) << endl;
   cout << "Size of double : " << sizeof(double) << endl;
   cout << "Size of wchar_t : " << sizeof(wchar_t) << endl;
   return 0;

End of preview.

Loved the preview? Share it!


Available Q4 2017.