Prepared by: Elsy Torres Shajida Berry Siobhan Westby.

15
Prepared by: Elsy Torres Shajida Berry Siobhan Westby

Transcript of Prepared by: Elsy Torres Shajida Berry Siobhan Westby.

Page 1: Prepared by: Elsy Torres Shajida Berry Siobhan Westby.

Prepared by:Elsy Torres

Shajida BerrySiobhan Westby

Page 2: Prepared by: Elsy Torres Shajida Berry Siobhan Westby.

Basic InformationComputer programmers have their own

languages that pretty much make no sense to anybody else.

C⁺⁺ being one of them.In 1980, Bjarne Stroustrup, from Bell labs, began

the development of the C++ language, that would receive formally this name at the end of 1983, when its first manual was going to be published. In October 1985, the first commercial release of the language appeared as well as the first edition of the book "The C++ Programming Language" by Bjarne Stroustrup.

Page 3: Prepared by: Elsy Torres Shajida Berry Siobhan Westby.

Basic InformationDuring the 80s, the C++ language was being

refined until it became a language with its own personality. All that with very few losses of compatibility with the code with C, and without resigning to its most important characteristics. In fact, the ANSI standard for the C language published in 1989 took good part of the contributions of C++ to structured programming.

Page 4: Prepared by: Elsy Torres Shajida Berry Siobhan Westby.

Basic FeaturesLike any other programming language, C++

uses data types to store values and information in. Here you can find a small list of the most used data types.

Int (integer value) Float (decimal value) Char (a character, contains text) Bool (boolean, true or false)

Page 5: Prepared by: Elsy Torres Shajida Berry Siobhan Westby.

Basic FeaturesWhen you are coding and you want to store a value,

you will have to know two things. First, what kind of data should the variable be able to handle? Second, what will the variable be called?

This is how you declare those four data types.int ThisIsAIntegerValue;

float ThisIsADecimalValue; char ThisIsACharacterVariable; bool ThisIsABoolean;

As you can see you first write the data type, after that, it's name, and then you have to finish the declaring with a ";".

Page 6: Prepared by: Elsy Torres Shajida Berry Siobhan Westby.

Basic FeaturesC++ is a multiparadigm language. This allows

developers to choose the programming style that is right for the task at hand. For example, a traditional procedural style may be appropriate for performing a simple task such as writing the code within a small member function.

C++ software can be performance and memory efficient. For example, well-designed, object oriented software is normally comprehensible and therefore amenable to performance tuning.

C++ is backward compatible with C. This is useful in very large legacy systems where the migration to C++ normally occurs a few subsystems at a time rather than all at once

Page 7: Prepared by: Elsy Torres Shajida Berry Siobhan Westby.

Object-oriented programming languages:Objects: Object is the basic unit of object-oriented

programming. Objects are identified by its unique name. An object represents a particular instance of a class. There can be more than one instance of an object. Each instance of an object can hold its own relevant data.

An Object is a collection of data members and associated member functions also known as methods.

Page 8: Prepared by: Elsy Torres Shajida Berry Siobhan Westby.
Page 9: Prepared by: Elsy Torres Shajida Berry Siobhan Westby.

Classes: are data types based on which objects are

created. Objects with similar properties and methods are grouped together to form a Class. Thus a Class represent a set of individual objects. Characteristics of an object are represented in a class as Properties. The actions that can be performed by objects becomes functions of the class and is referred to as Methods.

No memory is allocated when a class is created. Memory is allocated only when an object is created, i.e., when an instance of a class is created.

Page 10: Prepared by: Elsy Torres Shajida Berry Siobhan Westby.

Inheritance: is the process of forming a new class from an

existing class or base class. The base class is also known as parent class or super class, The new class that is formed is called derived class. Derived class is also known as a child class or sub class. It helps in reducing the overall code size of the program, which is an important concept in object-oriented programming

Page 11: Prepared by: Elsy Torres Shajida Berry Siobhan Westby.

Data Abstraction: increases the power of programming language

by creating user defined data types. It also represents the needed information in the program without presenting the details.

Data Encapsulation: combines data and functions into a single unit

called Class. When using it, data is not accessed directly; it is only accessible through the functions present inside the class. It enables the important concept of data hiding possible

Page 12: Prepared by: Elsy Torres Shajida Berry Siobhan Westby.

Polymorphism: allows routines to use variables of different types

at different times. An operator or function can be given different meanings or functions. It refers to a single function or multi-functioning operator performing in different ways.

Overloading: is one type of Polymorphism. It allows an object

to have different meanings, depending on its context. When an exiting operator or function begins to operate on new data type, or class, it is understood to be overloaded.

Reusability: This term refers to the ability for multiple

programmers to use the same written and debugged existing class of data. This is a time saving device and adds code efficiency to the language.

Page 13: Prepared by: Elsy Torres Shajida Berry Siobhan Westby.

AdvantagesBecause C++ is an object-oriented

programming language, it is designed to allow the creation and manipulation of objects from the problem domain.

allows programmers to operate at a higher level of abstraction.

A good abstraction allows users to use an object in a relatively safe and predictable manner

Page 14: Prepared by: Elsy Torres Shajida Berry Siobhan Westby.

ExamplePrinting Hello World!The first line in main uses the std::cout object to print the

string (sequence of characters) Hello World! and end the line:

std::cout << "Hello World!\n";

Adding Intergers#include<iostream> using namespace std; int main(){ int a = 3, b = 5; cout << a << '+' << b << '=' << (a+b); return 0;}

Page 15: Prepared by: Elsy Torres Shajida Berry Siobhan Westby.

Thank You