Object Oriented programming using C++ basic concepts

srinub16 16 views 16 slides Sep 21, 2024
Slide 1
Slide 1 of 16
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16

About This Presentation

CPP basic concepts


Slide Content

Object Oriented Programming using C++ Topic: Object Oriented Thinking

Programming Paradigms Need for OOP Procedure Oriented vs OOP OOP Concepts Abstraction Encapsulation Inheritance Polymorphism Contents

Programming Paradigms Procedure Oriented Programming Logic Programming Functional Programming Object Oriented Programming

Procedure Oriented Programming Emphasis on procedure in terms of underlying machine model. Ability to reuse the code Eg: C, PASCAL , C++

Procedure Oriented Programming Factorial Program in C: #include<stdio.h> int main() { int i,fact=1,number; printf("Enter a number: "); scanf("%d",&number); for(i=1;i<=number;i++){ fact=fact*i; } printf("Factorial of %d is: %d",number,fact); return 0; }

Logic Programming Emphasis on knowledge base and the problem Very much like proof of mathematical statement Solves logical problems like puzzles, series Eg: Prolog

Format : relation(entity1, entity2, ....k'th entity). Example : friends(raju, mahesh). singer(sonu). odd_number(5). These facts can be interpreted as : raju and mahesh are friends. sonu is a singer. 5 is an odd number. Logic Programming

Functional Programming Based on Mathemetical Functions and Lists Language independent Execution of series of Mathematical functions Eg: LISP , Javascript

Example – LISP: Factorial of ‘n’ Program: (defun factorial (n) (if (= n 0) 1 (* n (factorial (- n 1))) ) ) (loop for i from 0 to 16 do (format t "~D! = ~D~%" i (factorial i)) ) Functional Programming

Object Oriented Programming Emphasis on Data rather than Process. Object is the basic entity is object. Handle almost all kind of real life problems. Eg: SIMULA, SMALLTALK , C++, JAVA

Object Oriented Programming class factorial{ int f, n; public: void fact(); }; void factorial::fact() { f=1; cout<<"\nEnter a Number:"; cin>>n; for(int i=1;i<=n;i++) f=f*i; cout<<"\nFactorial of "<<n<<" is"<<f; } void main() { factorial ob; ob.fact(); getch(); }

Need for OOP To make your code: Easier to read, manage, update and implement. Performance improvement by fast execution Data Security Easy code updation Simplify

Eminent Persons Alan Kay Inventor – OOP Bjarne Stroustrup Inventor – C++ James Gosling Inventor- JAVA

POP vs OOP POP OOP Program is divided into functions. Program is divided into objects. Top-down approach. Bottom-up approach. Limited Data Security Data Security using access specifiers Examples: C, FORTRAN, Pascal, Basic etc. Examples: C++, Java, Python

OOP Concepts

Summary Programming Paradigms Object Oriented Programming POP vs OOP OOP Principles
Tags