oops and c++ fundamentals

16
Click to go my blog – http://excellentprogramming.blogspot.com

Upload: subhasis-nayak

Post on 22-May-2015

18.274 views

Category:

Education


2 download

DESCRIPTION

History of C++ andbasic concepts of object oriented programming.

TRANSCRIPT

Page 1: Oops And C++ Fundamentals

Click to go my blog – http://excellentprogramming.blogspot.com

Page 2: Oops And C++ Fundamentals

History of c++ Created by Bjarne stroustrup. The C language is still supported with C++. BCPL language contributed many ideas. Class and oop comes from Simula67. Originally known as c with class. C++ named by Rick Mascitti in 1983.

Page 3: Oops And C++ Fundamentals

Continue .... Still low level enough to be efficient. Still high level enough to be easy to code

in. Makes heavy use of additional libraries. Comes with intrinsic math function etc. Able to coexit with other language.

Page 4: Oops And C++ Fundamentals

Continue .... Will not help a bad programmer to be good one. Oop will assist in the design of the program. C is not necessary to know before C++. If you

know c , it’s good. But i am not recommmedning you to use some bad procedurial way of programming. So better stay away from those and make you life more easier with C++.

Page 5: Oops And C++ Fundamentals

Most used shortcut keys in TC As a good programmer you must use the

short cut keys. Save – F2 Compile – F9 Make – Alt+F9 Run – Ctrl+F9

Page 6: Oops And C++ Fundamentals

Your first programme Header file – the

function description and it’s action code in those file.

Main function – Your programe execution strats from here.

Hence all code must be inside of main function

Cout is used to display something on screen.

#include<stdio.h>#include<iostream.h>

int main(){cout<<"Hi! Welcome to OOP's world";return 0;}

Page 7: Oops And C++ Fundamentals

What Is Object-Oriented Programming? In structured programming techniques

programs are typically organized around code. In Object-oriented programming techniques

programs are organized around data, with the key principle being "data controlling access to code." In an object-oriented language, you define the data and the routines that are permitted to act on that data.

We must define precisely the data type what sort of operations can be applied to that data.

Page 8: Oops And C++ Fundamentals

Three traits of OOP According to the principles of object-

oriented programming, all OOP languages have three traits in common: Encapsulation Polymorphism inheritance

Page 9: Oops And C++ Fundamentals

Encapsulation Encapsulation is the mechanism that binds

together code and the data it manipulates. It keeps both safe from outside interference

and misuse. In object – oriented language code and data

may be combined in such a way that a self-contained "black box" is created.

Page 10: Oops And C++ Fundamentals

Continue .... code and data are linked together in this fashion, an

object is created. We can say this as an object is the device that supports encapsulation.

Within an object, code, data, or both may be private to that object or public.

An object is a variable of a user-defined type. We can use it as like variable. However, in object-oriented programming, Each time you define a new type of object, you are creating a new data type. Each specific instance of this data type is a compound variable.

Page 11: Oops And C++ Fundamentals

Private and public

Page 12: Oops And C++ Fundamentals

Polymorphism Polymorphism is characterized by the

phrase "one interface, multiple methods”. polymorphism is the attribute that allows

one interface to control access to a general class of actions.

The specific action selected is determined by the exact nature of the situation.

Page 13: Oops And C++ Fundamentals

Continue .... It helps reduce complexity by allowing the

same interface to be used to access a general class of actions.

It is not our job to select the specific action as it applies to each situation. It is the job of our compiler(which compiles your program writeen in high level language).

C++, both run-time and compile-time polymorphism are supported.

Page 14: Oops And C++ Fundamentals

Inheritance Inheritance is the process by which one object

can acquire the properties of another object like son has some father’s characters.

This is important because it supports the concept of classification.

Without inheritance we have to define properties or behaviour explicitly for each and every class even those are related to some one.

Page 15: Oops And C++ Fundamentals

Continue ....

Example of inheritance

Page 16: Oops And C++ Fundamentals

Continue .... However, through the use of

classifications, an object need only define those qualities that make it unique within its class. It is the inheritance mechanism that makes it possible for one object to be a specific instance of a more general case.

Go to my blog to download the program excellentprogramming