0% found this document useful (0 votes)
28 views

Object Oriented Programming: CSE 202 Dilpreet Kaur

C++ is an object-oriented programming language that improves on C by making data safer through data hiding, supporting features like function overloading and polymorphism, and allowing functions to be used inside structures. Some key benefits of object-oriented programming include inheritance which removes redundant code, data hiding for security, and the ability for multiple instances of an object to coexist. A basic C++ program structure includes header files, the main function, and output statements like cout.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views

Object Oriented Programming: CSE 202 Dilpreet Kaur

C++ is an object-oriented programming language that improves on C by making data safer through data hiding, supporting features like function overloading and polymorphism, and allowing functions to be used inside structures. Some key benefits of object-oriented programming include inheritance which removes redundant code, data hiding for security, and the ability for multiple instances of an object to coexist. A basic C++ program structure includes header files, the main function, and output statements like cout.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 11

OBJECT ORIENTED PROGRAMMING

CSE 202 Dilpreet Kaur

Difference between C and C++



C Procedural Paradigm Data not safe Low-level language Function Driven No function overloading Printf and scanf for output and input Functions are not used inside structure

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

Structure of C++ Program


A simple C++ Program # include<iostream.h> void main() { cout<< C++ is better than C. \n; }

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;

Writing and Editing Program


Text editor is used to write programs Simple text processing is different from writing programs After writing the program, saved file is called source file Source file is given as input to the compiler

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

You might also like