0% found this document useful (0 votes)
33 views15 pages

C++Lec2-Intro C++

The document discusses C++ programming language. It covers topics like what C++ is, its history, how it supports object-oriented programming, standard libraries, compilers, basic syntax including classes, objects, methods, arrays, and initializing arrays.

Uploaded by

haponabeel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views15 pages

C++Lec2-Intro C++

The document discusses C++ programming language. It covers topics like what C++ is, its history, how it supports object-oriented programming, standard libraries, compilers, basic syntax including classes, objects, methods, arrays, and initializing arrays.

Uploaded by

haponabeel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

C++

Lecture – 2

Dr. Aghabi Abosaif


October 2023

1
C++ Programming language
 C++ is a statically typed, compiled, general-purpose,
case-sensitive, free-form programming language that
supports procedural, object-oriented, and generic
programming.
 C++ is regarded as a middle-level language, as it
comprises a combination of both high-level and low-
level language features.
 C++ was developed by Bjarne Stroustrup starting in 1979
at Bell Labs in Murray Hill, New Jersey.
C++ Programming language
 It`s enhancement to the C language and originally named
C with Classes but later it was renamed C++ in 1983.

 A programming language is said to use static typing


when type checking is performed during compile-time as
opposed to run-time.
Object-Oriented Programming
 C++ fully supports object-oriented programming,
including the four pillars of object-oriented development:
 Encapsulation
 Data hiding
 Inheritance
 Polymorphism
Standard Libraries
 Standard C++ consists of three important parts:
 The core language giving all the building blocks
including variables, 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.
The ANSI Standard
 The ANSI standard is an attempt to ensure that C++ is
portable; that code you write for Microsoft's compiler
will compile without errors, using a compiler on a Mac,
UNIX, a Windows box.
C++ Compiler
 This is an actual C++ compiler, which will be used to
compile your source code into final executable program.

 Source code extension is .cpp by default.

 Most frequently used and free available compiler is GNU


C/C++ compiler.
Basic Syntax
 C++ program, it can be defined as a collection of objects
that communicate via invoking each other's methods.

 Object - Objects have states and behaviors. Example: A


dog has states - color, name, breed as well as behaviors -
wagging, barking, and eating. An object is an instance of
a class.

 Class - A class can be defined as a template/blueprint


that describes the behaviors/states that object of its type
support.
Basic Syntax
 Methods - A method is basically a behavior. A class can
contain many methods. It is in methods where the logics
are written, data is manipulated and all the actions are
executed.

 Instant Variables - Each object has its unique set of


instant variables. An object's state is created by the
values assigned to these instant variables.
C++ Arrays
 C++ provides an array data structure, which stores a fixed-size
sequential collection of elements of the same type.
 It is often more useful to think of an array as a collection of
variables of the same type.

 Instead of declaring individual variables, such as number0,..., and


number99, you declare one array variable such as numbers and
use numbers[0], ..., numbers[99] to represent individual variables.

 Element in an array is accessed by an index.

 All arrays consist of contiguous memory locations. The lowest


address corresponds to the first element and the highest address
to the last element.
Declaring Arrays
 To declare an array in C++, the programmer specifies the
type of the elements array name , arrayNmae and the
number of elements required by an array.

 The array-Size must be an integer constant greater than


zero and type can be any valid C++ data type.
Initializing Arrays
 You can initialize C++ array elements either one by one or using a
single statement.
 The number of values between braces { } cannot be larger than
the number of elements that we declare for the array between
square brackets [ ].
 If you omit the size of the array, an array just big enough to hold
the initialization is created.
Declaring Arrays
 To declare an array in C++, the programmer specifies the
type of the elements array name , array and the number
of elements required by an array as follows
Put Technology in Action
 Technology on the world stage.

You might also like