Operator overloading refers to providing meaning that extends beyond their predefined operational meaning. For example, the operator + can be used to add two integers, join two strings, or merge two lists. It is possible because the ‘+’ operator is overloaded by the int and str classes. Therefore, the different behavior of a single operator […]
December 18, 2022 | python | No comments
Class or Static Variables: In Python, a variable declared within a class but outside any method is referred to as a class or static variable. A class or static variable can be referred to, but not directly through an instance. Class or static variables are distinct from and do not conflict with other member variables […]
December 17, 2022 | python | No comments
What is Polymorphism? Polymorphism is derived from the Greek words poly (many) and morphism (change) (forms). That is, the same function name can be used for multiple types. This makes programming more intuitive and straightforward. Polymorphism can be defined in a variety of ways in Python. So, let’s start and look at how polymorphism works […]
December 16, 2022 | python | No comments
Method overriding is a feature of any object-oriented programming language that allows a subclass or child class to implement a method that is already provided by one of its super-classes or parent classes. When a method in a subclass has the same name, parameters or signature, and return type (or sub-type) as a method in […]
December 15, 2022 | python | No comments
Types of Inheritance depend upon the number of child and parent classes involved. There are four types of inheritance in Python: Single Inheritance Multiple Inheritance Multilevel Inheritance Hierarchical Inheritance Single Inheritance: Single inheritance allows for the inheritance of properties from a single parent class by a derived class, allowing for the reuse of existing code […]
December 12, 2022 | python | No comments
Inheritance is a fundamental idea in object-oriented programming (OOP) languages. By deriving a class from another class, you can use this mechanism to build a hierarchy of classes that share a set of properties and methods. Benefits of inheritance include: It accurately depicts real-world relationships. It offers a code’s reusability. We don’t need to keep […]
December 12, 2022 | python | No comments
When an object is destroyed, the destructors are called. Destructors are not as necessary in Python as they are in C++ because Python has a garbage collector that manages memory automatically. The _del_() method in Python is known as a destructor method. When an object is garbage collected, or when all references to the object […]
December 12, 2022 | python | No comments
What is a Constructor? A constructor is a special method (function) used to initialize the class’s instance members. The main goal of constructors is to assign values to the class’s data members when an object of the class is created. Constructors are always called when an object is created, and the init() method simulates this. It […]
December 9, 2022 | python | No comments
As we discussed in the previous tutorial, a class is a virtual entity that can be thought of as an object’s blueprint. The class was created when it was instantiated. Let us illustrate this with an example. Assume a class is a building prototype. A building contains all the information about the floor, rooms, doors, […]
December 8, 2022 | python | No comments
What is Operator Overloading? Operator overloading is a compile-time polymorphism in which the operator is overloaded to provide the user-defined data type with a special meaning. Most of the operators available in C++ are overloaded or redefined using operator overloading. It’s used to run an operation on a user-defined data type. Operators that can be […]
October 29, 2022 | C++ | No comments