THE CONCEPT OF INHERITANCE IN C++

Hello everyone!! Welcome to help Hindi. In this blog we have explained about the concept of inheritance in C++. After reading all the things you will be able to understand the concept of inheritance, what is the meaning of inheritance in C++ and what are the types of inheritance. So let us discuss it one by one.

What is inheritance?

Before going to the concept of INHERITANCE IN C++, do we need to understand what inheritance is? So, the mechanism of deriving a new class from a previously existing class is called inheritance. The existing class is called the base class and the new class is called the derived class. Inheritance helps us reuse the code and increase code, so also efficiency and organization. It facilitates maintenance and updates. The capability of a class to drive properties and characteristics from another class is called inheritance. Inheritance is a process in which one object acquires all the properties and behaviors of its parents objects automatically.

A – the base class or super class or parent class

B – derived class or subclass or child class

     The class in which the members of another class are inherited is called a derivative class, and the class whose members are inherited is called a base class.

				
					Syntax

Ctrl+O Class derived- class name: visibility meet base class name

{

// Body of the derived Class

}
				
			

types of inheritance –

  1. Single Inheritance
  2. Multilevel Inheritance
  3. hierarchical Inheritance
  4. Multiple Inheritance
  5. Hybrid Inheritance
  6. Multipath Inheritance

A derived class with only a base class is called single inheritance. Here are some examples of this inheritance. For example, WAP to create two student & result. Student class contains & name as its data member and result class contains 3 subject marks. Display roll, name, total mark and percentage. We can understand by following image.

				
					class Parent {
// properties and methods of the parent class
}class Child extends Parent {
//properties and methods of the parent class

}
				
			

2.Multilevel Inheritance

   Multilevel inheritance is another type of inheritance. It is a feature of object-oriented programming, where a subclass or derived class inherits properties and methods from a parent or base class. which further, it is derived from another parent or base class.  So, this creates a chain of inheritance relationships, where it is a derived class that is inherited by a base class which itself inherits from another base class. Here’s an example of multilevel inheritance in Python:

				
					class Grandparent:
def method1(self):
print("This is method1 from Grandparent class")class Parent(Grandparent):
def method2(self):
print("This is method2 from Parent class")class Child(Parent):
def method3(self):
print("This is method3 from Child class")
				
			

In the above example, the Grandparent class represents the base class.

Where, as the Parent class shows, the derived class that inherits from the class.

And the Child class shows another derived class that inherits from the class.

It is briefly already in our notes, please go and download it.

3-hierarchical inheritance

in this inheritance type the properties of one class (base class) want to 2 classes.
 
 

So, it is a type of inheritance which is related to object-oriented programming, which means a subclass or child class inherits properties. And the methods from its to super class or parent class. That is itself can also have its own super class.

4-Multiple inheritance

It is a feature of object-oriented programming languages. It allows to a class to inherit from more than one parent class. In another way it is a class can have multiple super classes from which it can inherit attributes or we can say methods. It can be understand by the given image.
 

5-HYBRID Inheritance

Hybrid inheritance is another type of inheritance which combines both the features Thai is single inheritance and multiple inheritance in the object-oriented programming. In hybrid inheritance type, a class is derived from two or more base classes. And which is one of the base classes in a combination of two or more classes. This results in a hierarchy of classes that share attributes or we can say methods, whichmakes code to reuse more efficient. This is explained by a diagram which is given by an image.

6-Multipath Inheritance

             Multipath inheritance includes a hybrid of multiple, multi-level, and hierarchical inheritance. A parent class provides their features and functions to the child class, which is known as multipath inheritance. So also a child class derives its functions from several child classes.It can be understood by a given picture.

 

FAQ

questions

Ans- Basically C++  is a feature of inheritance which is based on base class or existing class and the existing class is also known as  the base class.

Ans- derived class in c++ can be defined as, another class i.e. base class or parent class.

LETS LEARN

Quotation marks within a string in java

                        Hello everyone!! Welcome to help Hindi. In this blog we have explained the concept of quotation marks within a string in java. After reading all the things you will be able to understand the concept of what is the meaning of quotation marks within a string in java and how to add quotation marks within a string in java and also related topics.

What are the quotation marks in programming?

Generally, these marks are indicating the punctuation marks which are used to indicate a direct quote or a piece of text which is referred directly, so also, they sometimes called speech marks or inverted commas, which is used in the operation of programming. Quotation marks are generally represented in writing as a pair of vertical marks i.e. (“) which are placed before and after the quoted text. But in programming language quotation marks are used to represent string literals, which are sequences of characters enclosed in quotes.  It is indicated by,

				
					String message = "Hello, world!";
				
			

USES OF QUOTATION MARKS

Generally, these marks are used in many contexts, such as:
  • Direct speech: – It means the exact words or sentences which are spoken by someone, when a character in a film or story speaks. their words are often enclosed in quotation marks which indicate that they are speaking for Example: –  “Hello,” said John.

 

  • Quoting text: It refers to the act of reproducing or repeating a piece of text verbatim from its original source. When quoting a piece of text directly, it means that quotation marks are used to indicate that the words are not the writer’s own, for example- According to the article, “The problem is not going away anytime soon.”
  • Titles: – it refers to the names which are given to different components of a program, such as – classes, methods, or variables, etc. basically, these marks can be used to indicate the title of a shorter work, for example: –   An article or a chapter within a book.

                    But in programming language these marks are used to represent string literals, which are sequences of characters enclosed in quotes.  The following uses are following below-

1.Declaring string literals: It defines a sequence of characters enclosed in quotation marks which represents a string value. In most programming languages, string literals are enclosed in quotation marks to differentiate them from other types of data. For example – in python,

				
					message = Hello, World!"
				
			

in the above example the string literal is "Hello, World!" and it is assigned to the variable  message .

2.Escaping special characters: –

                      It means it is a line breaks or backslash (” “) in most programming languages, to indicate that a character should be treated differently than its literal meaning.  In some cases, string literals may contain special characters such that need to be escaped. In these cases, the special characters are preceded by a backslash () which indicate that they should be treated as literal characters. for example in python-

				
					string_with_quotes = "She said, "Hello!""
				
			
				
					String message = "She said, "I'm busy right now."";
String path = "C:\Users\John\Documents\file.txt";
String multiLine = "This is a multi-linen string.";
				
			

3) Singular expressions:

                   It refers to a sequence of characters and symbols that define a search pattern. Generally, these are the powerful tools which are used in computer science, programming, and so also in data analysis for matching and manipulating strings. In JavaScript it is looking like this-

				
					var pattern = /[aeiou]/; // Matches any vowel
var pattern2 = /d+/; // Matches one or more digits
var pattern3 = /"[^"]*"/; // Matches a quoted string
				
			

    All the above discussions are the uses of quotation marks in programming language and these marks are very important in programming language. Now we further we discuss how we can add the quotation marks in within a string in java –

how to add quotation marks within a string in java?

                      Generally it is add In Java,python, javascript,swift or other programming languages.It can add quotation marks within a string by using escape characters. to understand  we gave an example,

in the case of swift –

				
					string myString = "He said, "Hello World!"";
				
			

in the case of javascript

				
					string myString = "He said, 'Java is fun!'";
				
			

in the case of java 

				
					string myString = "He said, 'Java is fun!'";
				
			

and in the case of python

				
					 string_with_quotes = "She said, "Hello!""
				
			

So, all the above discussion represented the meaning of quotation marks and how to use it in programming. We hope you understood. Thank you 

FAQ

it is a variable is a named storage location in a program

Functions in function can be called from different parts of a program to execute the same code without having to repeat it.

basically loop is a control structure, in which a program that repeats a block of code until a certain condition is met.

It is an object-oriented programming is a programming paradigm that uses in objects.

A compiler is a software tool which translates high-level source code.

THE CONCEPT OF PROGRAMMING LANGUAGE

                            Hello friends, welcome to HelpHindi. In this blog we have explained  about the concept of programming language. After reading all the things you will be able to understand the concept of programming language and what are the types of of programming language and their meaning.

basic concept of programming language

Generally , The learning of the concept of Programming language are very important in the modern world because  their  used in modern time very large level such as  to create software, applications, and other digital solutions.  So the concept of programming language is basically set of rules or symbols or codes  which is use to write instructions for computers to execute and runs. However the purpose of a programming language is to provide a way for humans to communicate with machines.

 Types of Programming Language 

Literally,the concept of  programming language are each with its own syntax(it means principle), structure, and purpose. So also Some programming languages are designed for specific tasks such as:- web development, data analysis, or mobile app development,etc. can be used for a wide range of applications.

So there are 6 popular programming languages they are following bellow:-

            • JAVA
            • PYTHON
            • JAVASCIRPT
            • C++
            • SWIFT
            • RUBY

Read more