Posts

Basic of C LANGUAGE

Image
 

Question:-Oearriding in c++.

 Function Overriding in C++:- A function is a block of statements that together performs a specific task by taking some input and producing a particular output. Function overriding in C++ is termed as the redefinition of base class function in its derived class with the same signature i.e. return type and parameters. It falls under the category of Runtime Polymorphism. Real-Life Example of Function Overriding The best Real-life example of this concept is the Constitution of India. India took the political code, structure, procedures, powers, and duties of government institutions and set out fundamental rights, directive principles, and the duties of citizens of other countries and implemented them on its own; making it the biggest constitution in the world.  Another Development real-life example could be the relationship between RBI(The Reserve Bank of India) and Other state banks like SBI, PNB, ICICI, etc. Where the RBI passes the same regulatory function and others follow it...

Question:- overloding inc++.

Function Overloading in C++:- Function overloading is a feature of object-oriented programming where two or more functions can have the same name but different parameters. When a function name is overloaded with different jobs it is called Function Overloading. In Function Overloading “Function” name should be the same and the arguments should be different. Function overloading can be considered as an example of a polymorphism feature in C++. The parameters should follow any one or more than one of the following conditions for Function overloading: Parameters should have a different type add(int a, int b) add(double a, double b) Below is the implementation of the above discussion: #include <iostream> using namespace std;  void add(int a, int b) {  cout << "sum = " << (a + b); }  void add(double a, double b) {  cout << endl << "sum = " << (a + b); }  // Driver code int main() {  add(10, 2);    add(5.3, 6.2); ...

Question:-WHAT IS POLYMORPHIC IN C++?

  Polymorphism Polymorphism means "many forms", and it occurs when we have many classes that are related to each other by inheritance. Like we specified in the previous chapter;  Inheritance  lets us inherit attributes and methods from another class.  Polymorphism  uses those methods to perform different tasks. This allows us to perform a single action in different ways. For example, think of a base class called  Animal  that has a method called  animalSound() . Derived classes of Animals could be Pigs, Cats, Dogs, Birds - And they also have their own implementation of an animal sound (the pig oinks, and the cat meows, etc.): Example // Base class class  Animal {    public :      void   animalSound() {       cout <<  "The animal makes a sound \n" ;     } }; // Derived class class  Pig :  public  Animal {    public :   ...

Question:- WHAT IS INHERITENCE IN C++?

Image
  The capability of a   class  to derive properties and characteristics from another class is called   Inheritance . Inheritance is one of the most important features of Object-Oriented Programming.  Inheritance is a feature or a process in which, new classes are created from the existing classes. The new class created is called “derived class” or “child class” and the existing class is known as the “base class” or “parent class”. The derived class now is said to be inherited from the base class. When we say derived class inherits the base class, it means, the derived class inherits all the properties of the base class, without changing the properties of base class and may add new features to its own. These new features in the derived class will not affect the base class. The derived class is the specialized class for the base class. Sub Class:  The class that inherits properties from another class is called Subclass or Derived Class.  Super Class:...