0% found this document useful (0 votes)
9 views14 pages

Lec1 Notes

The document discusses the advantages and disadvantages of the C programming language, highlighting its portability, modularity, and speed, while noting its lack of object-oriented features. It contrasts C with C++, explaining that C++ supports object-oriented programming concepts such as polymorphism, encapsulation, and inheritance. Additionally, it provides an overview of object-oriented programming principles and includes a class example to illustrate these concepts.

Uploaded by

sidchan4
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views14 pages

Lec1 Notes

The document discusses the advantages and disadvantages of the C programming language, highlighting its portability, modularity, and speed, while noting its lack of object-oriented features. It contrasts C with C++, explaining that C++ supports object-oriented programming concepts such as polymorphism, encapsulation, and inheritance. Additionally, it provides an overview of object-oriented programming principles and includes a class example to illustrate these concepts.

Uploaded by

sidchan4
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

Object-Oriented

Programming (OOP)
IT203
C language advantages:
• Portability: It refers to the usability of the same fragment of code in different
environments. C programs are capable of being written on one platform and being
run on another with or without any modification.
• Modularity/Structured Language: This feature of C language allows the program to
be splintered (broken) into smaller units and run individually with the help of
functions.
• Simple and Efficient
• Speed: Since it is a compiler-based language, it is comparatively faster than other
programming languages like Java or Python, which are interpreter based.
• Popular: It is one of the most extensively used languages in the development of
operating and embedded systems
• Existence of Libraries: C language comprises of its library which has a wide range
of built-in functions. Even the user-defined functions can be added to the C library.
• Dynamism: It supports the feature of DMA (Dynamic Memory
Allocation), which helps in the utilization and management of
memory. Among all the features of C, dynamism is unique.
Using DMA, the size of a data structure can be changed during
runtime using some predefined functions in the C library such
as malloc(), calloc(), free() and realloc().
Disadvantages of C Programming Language:

• C does not have the concept of OOPs, that’s why C++ is


developed.
• It doesn’t contain run-time checking. We can pass an integer
value for the floating data type.
• As the program extends it is very difficult to fix the bugs.
• C doesn’t have the concept of namespace.
• C doesn’t have the concept of constructor or destructor.
What is Object Oriented Programming
(OOP)?
• An object-oriented programming is a way programming which
enables programmers to think like they are working with real-life
entities(a thing with distinct and independent existence) or
objects. In real-life, people have knowledge and can do various
works.
• In OOP, objects have fields to store knowledge/state/data and
can do various works — methods.
Example : AC
Properties/attributes:
-> Name
-> model_no
-> price
-> company
Rating
Methods()/working()/functions()
------wifi()
------selfclean()
------purify_air()
------energy_save()
Features of OOP
Abstraction:

>Data Hiding
>Unnecessary details are hidden from
the user
>outer interface is only required
Encapsulation:
• > wrapping up data and
functions under one name
polymorphism:
• One name, different forms
Inheritance:

A/c’s newer models have inherited old


features as well as added their own
C vs C++
C Language C++
C was developed by Dennis Ritchie between the year 1969 and
C++ was developed by Bjarne Stroustrup in 1979.
1973 at AT&T Bell Labs.
C does no support polymorphism, encapsulation, and C++ supports polymorphism, encapsulation,
inheritance which means that C does not support object and inheritance because it is an object oriented programming
oriented programming. language.
C is a subset of C++. C++ is a superset of C.
C contains 32 keywords. C++ contains 52 keywords.
For the development of code, C supports procedural C++ is known as hybrid language because C++ supports
programming. both procedural and object oriented programming paradigms.
Data and functions are separated in C because it is a procedural Data and functions are encapsulated together in form of an
programming language. object in C++.
Data is hidden by the Encapsulation to ensure that data
C does not support information hiding.
structures and operators are used as intended.
Built-in data types is supported in C. Built-in & user-defined data types is supported in C++.
C is a function driven language because C is a procedural C++ is an object driven language because it is an object
programming language. oriented programming.
C vs C++ contd..
C Language C++
Function and operator overloading is not supported in C. Function and operator overloading is supported by C++.
C is a function-driven language. C++ is an object-driven language
Functions in C are not defined inside structures. Functions can be used inside a structure in C++.
Namespace features are not present inside the C. Namespace is used by C++, which avoid name collisions.
Header file used by C is stdio.h. Header file used by C++ is iostream.h.
Reference variables are not supported by C. Reference variables are supported by C++.
Virtual and friend functions are not supported by C. Virtual and friend functions are supported by C++.
C does not support inheritance. C++ supports inheritance.
C++ focuses on data instead of focusing on method or
Instead of focusing on data, C focuses on method or process.
procedure.
C provides malloc() and calloc() functions for dynamic memory C++ provides new operator for memory allocation and delete
allocation, and free() for memory de-allocation. operator for memory de-allocation.
Direct support for exception handling is not supported by C. Exception handling is supported by C++.
scanf() and printf() functions are used for input/output in C. cin>> ,cout<< are used
Class Cube
Side As Real
Volume As Real
Subprogram SetSide(NewSide)
Set Side = NewSide
End Subprogram
Subprogram ComputeVolume()
Set Volume = Side ^ 3
End Subprogram
Function GetVolume() As Real
Set GetVolume = Volume
End Function
Function GetSide() As Real
Set GetSide = Side
End Function
End Class

You might also like