Download
Download
Study Materials
Similarities between C and C++:
• Both the languages have a similar syntax.
• Code structure of both the languages are same.
• The compilation of both the languages is similar.
• They share the same basic syntax. Nearly all of C’s operators and keywords are
also present in C++ and do the same thing.
• C++ has a slightly extended grammar than C, but the basic grammar is the same.
• Basic memory model of both is very close to the hardware.
• Same notions of stack, heap, file-scope and static variables are present in both
the languages.
Differences between C and C++ are:
• C++ is often viewed as a superset of C.
• C++ is also known as a C with class This was very nearly true when C++ was originally
created, but the two languages have evolved over time with C picking up a number of
features that either weren’t found in the contemporary version of C++ or still haven’t
made it into any version of C++.
• That said, C++ is still mostly a superset of C adding Object-Oriented Programming,
Exception Handling, Templating, and a more extensive standard library
C VS C++:
C VS C++:
C VS C++:
Object Oriented Programming:
• Class
• Objects
• Data Abstraction
• Encapsulation
• Inheritance
• Polymorphism
1. Class:
• A class is a user-defined data type. It consists of data members and member
functions, which can be accessed and used by creating an instance of that class.
• It represents the set of properties or methods that are common to all objects of
one type.
• A class is like a blueprint for an object.
• For Example: Consider the Class of Cars. There may be many cars with different
names and brands but all of them will share some common properties like all of
them will have 4 wheels, Speed Limit, Mileage range, etc. So here, Car is the class,
and wheels, speed limits, mileage are their properties.
2. Object:
• Inheritance is a mechanism in which one object acquires all the properties and
behaviors of a parent object.
• It is an important part of OOPs (Object Oriented programming system).
• The idea behind inheritance is that you can create new classes that are built upon
existing classes. There are 5 types of inheritance
• Single-level inheritance
• Multi-level Inheritance
• Hierarchical Inheritance
• Multiple Inheritance
• Hybrid Inheritance.
4.Polymorphism:
Types of Polymorphism:
• Compile-time Polymorphism
• Runtime Polymorphism
5. Encapsulation: