Object Oriented Programming: CSE 202 Dilpreet Kaur
Object Oriented Programming: CSE 202 Dilpreet Kaur
C++ Object Oriented Paradigm Data safe due to data hiding Middle-level Language Object Driven Supports Function Overloading Cout and cin for output and input Functions can be used inside structure
Drawbacks of C
More emphasis on procedure Data not Secure No function overloading Cant use functions inside the structure More function driven No polymorphism No inheritance
Benefits of OOPs
Inheritance removes redundant code Data hiding helps to build secure programs Multiple instances of an object can co-exist Work is partitioned using objects A function with same name can be used at multiple places
Identifiers
Allows to name data and other objects First character must be alphanumeric or underscore Identifier cannot duplicate a reserved word Valid Names Invalid Names
a Student_name _aSystemName pi a1 stdntNm _anthrSysNm PI $sum // $ is illegal 2names //cant start with 2 Stdnt Nmbr // no spaces Int //researved word
Data Types
Standard types Void Int Char Float Bool Derived types Pointer Union Array Structure Class
Variables
Named memory locations Declared and defined at the same time For exp: char code; int i; float percentage; bool valid;
Compiling Programs
Source file translated to machine language C++ compiler works as preprocessor and translator Preprocessor reads source code and prepares it for translator Result of preprocessing is translation unit Translator converts program to machine code
Linking Programs
C++ program contains many functions Linking of user-defined and inbuilt functions is done Linker assembles all functions giving an executable code