suraakshitha / Akshitha

0 stars 0 forks source link

ASSIGNMENT 3 #3

Open suraakshitha opened 1 year ago

suraakshitha commented 1 year ago
What is C++?

C++ is an object-oriented programming (OOP) language that is viewed by many as the best language for creating large-scale applications. C++ is a superset of the C language.A related programming language, Java, is based on C++ but optimized for the distribution of program objects in a network such as the Internet. Java is somewhat simpler and easier to learn than C++ and has characteristics that give it other advantages over C++. However, both languages require a considerable amount of study.

A "Hello, World!" is a simple program that outputs Hello, World! on the screen. Since it's a very simple program, it's often used to introduce a new programming language to a newbie.Let's see how C++ "Hello, World!" program works.

Let us now look at the program :

#include
int main()
{
cout <<"Hello World" ;
return 0;
}

C++ is an object oriented programming language.
The main pillars of objects oriented programming are :

  • Objects and Classes
  • Inheritance
  • Polymorphism
  • Abstraction
  • Encapsulation

The word object-oriented is the combination of two words i.e. object and oriented. The dictionary meaning of the object is an article or entity that exists in the real world. The meaning of oriented is interested in a particular kind of thing or entity. In layman's terms, it is a programming pattern that rounds around an object or entity are called object-oriented programming.

Object : The word object-oriented is the combination of two words i.e. object and oriented. The dictionary meaning of the object is an article or entity that exists in the real world. The meaning of oriented is interested in aparticular kind of thing or entity. In layman's terms, it is a programming pattern that rounds around an object or entity are called object-oriented programming.
Class :Attributes and methods are basically variables and functions that belongs to the class. These are often referred to as "class members".A class is a user-defined data type that we can use in our program, and it works as an object constructor, or a "blueprint" for creating objects.

Inheritance

Inheritance is a mechanism of reusing and extending existing classes without modifying them, thus producing hierarchical relationships between them. Inheritance is almost like embedding an object into a class.

Mode of Inheritance :

Public Mode :public inheritance makes public members of the base class public in the derived class, and the protected members of the base class remain protected in the derived class. protected inheritance makes the public and protected members of the base class protected in the derived class.

Protected Mode :When deriving from a protected base class, public and protected members of the base class become protected members of the derived class. Private Inheritance − When deriving from a private base class, public and protected members of the base class become private members of the derived class.

Private Mode :private inheritance means that implementation only should be inherited; interface should be ignored. If D privately inherits from B, it means that D objects are implemented in terms of B objects, nothing more. Private inheritance means nothing during software design, only during software implementation."

Types of Inheritance in C++ :


Single Inheritance :In C++, inheritance is a process in which one object acquires all the properties and behaviors of its parent object automatically. In such way, you can reuse, extend or modify the attributes and behaviors which are defined in other class.In C++, the class which inherits the members of another class is called derived class and the class whose members are inherited is called base class. The derived class is the specialized class for the base class.

Multiple Inheritance :Multiple Inheritance is a feature of C++ where a class can inherit from more than one classes. The constructors of inherited classes are called in the same order in which they are inherited. For example, in the following program, B’s constructor is called before A’s constructor.

Multilevel Inheritance :In C++ programming, not only you can derive a class from the base class but you can also derive a class from the derived class. This form of inheritance is known as multilevel inheritance.

Hieratical Inheritance :Hierarchical Inheritance in C++ refers to the type of inheritance that has a hierarchical structure of classes. A single base class can have multiple derived classes, and other subclasses can further inherit these derived classes, forming a hierarchy of classes.

Hybrid Inheritance :Hybrid Inheritance in C++ is the process by which a sub class follows multiple types of inheritance while deriving properties from the base or super class. This is also known as Multipath Inheritance for the same reason.

Polymorphism

Polymorphism : “polymorphism” means having many forms. In simple words, we can define polymorphism as the ability of a message to be displayed in more than one form. A real-life example of polymorphism is a person who at the same time can have different characteristics. A man at the same time is a father, a husband, and an employee. So the same person exhibits different behavior in different situations. This is called polymorphism. Polymorphism is considered one of the important features of Object-Oriented Programming.

In C++ Polymorphism is mainly divided into 2 types :
1. Compiletime Polymorphism
2. Runtime Polymorphism

Compiletime Polymorphism :When the relationship between the definition of different functions and their function calls, is determined during the compile-time, it is known as compile-time polymorphism. This type of polymorphism is also known as static or early binding polymorphism.
Runtime Polymorphism :Runtime polymorphism is also known as dynamic polymorphism or late binding. In runtime polymorphism, the function call is resolved at run time.

Abstraction

Abstraction is the process of only showing the necessary details to the user and hiding the other details in the background. Control and data are the two types of abstraction in C++. Abstraction in C++ is achieved through classes, header files, and access specifiers.

Abstraction using classes :An abstract class is a class that is designed to be specifically used as a base class. An abstract class contains at least one pure virtual function. You declare a pure virtual function by using a pure specifier ( = 0 ) in the declaration of a virtual member function in the class declaration.
Abstraction in header files :Data abstraction is one of the most essential and important features of object-oriented programming in C++. Abstraction means displaying only essential information and hiding the details. Data abstraction refers to providing only essential information about the data to the outside world, hiding the background details or implementation.

Encapsulation

Encapsulation : Encapsulation, in the context of C#, refers to an object's ability to hide data and behavior that are not necessary to its user. Encapsulation enables a group of properties, methods and other members to be considered a single unit or object.

suraakshitha commented 1 year ago

div.main-body { display: grid; grid-template-columns: minmax(300px,auto)fr; grid-template-areas: "navbar mainContent"; grid-gap: 20px; } nav#navbar { grid-area: navbar; position: fixed; } nav#navbar a{ display: block; border: 1px,solid black; padding: 5px; margin: 10px 0; text-decoration: none; color: black; } main#main-doc { grid-area: mainContent; } header { font-size: 1.5rem; font-weight: bold; } code { background-color: #CCC; display: block; padding: 20px; };