Skip to main content

Posts

Showing posts from September, 2025

Introduction to Supervised Machine Learning: Step-by-Step Guide for Beginner

  What is Supervised Machine Learning? Supervised Machine Learning is training a computer in the same way that we train children using examples. Let’s break it step by step Example with Fruits Consider a scenario where you are training a child on how to identify fruits. You show an apple and say, “This is an apple.” You show a banana and say, “This is a banana.” After watching lots of apples and bananas the child begins to notice the patterns : Apples are usually round, red, or green. Bananas are long and yellow. Next time even when you give the child a new apple (not the one you showed him or her before) the child is able to say:  “That looks like an apple!” How Computers Learn in the Same Way In supervised ML: Input (Data) = The items that we present to the computer (such as images of fruits, emails or medical records of patients). Output (Label/Correct Answer) = What the data really is (Apple, Banana, Spam, Not Spam, Healthy, Sick). Lea...

Introduction to Machine Learning – A Beginner’s Guide

The world we live in is a technologically oriented one. Apps that suggest songs, recommend movies, translate languages, identify our faces and even drive cars automatically are used every day. Behind all this progress is something called  Machine Learning (ML) . This blog will describe what Machine Learning is, how it functions, the variations, and the real life examples of this which we can see in our everyday lives in the most simplistic manner. What is Machine Learning? Suppose you have to teach a child to identify fruits. You do not give them a list of rules such as: An apple is round. A banana is long. A mango is yellow. Rather, you  show numerous pictures  of apples, bananas, and mangoes. After enough examples, the child starts to recognize them on their own. Machine Learning is precisely this. It is a way of training  computers to learn from data and examples instead of hard-coded rules . Instead of coding each step we allow the computer to identify patterns...

Early vs Late Binding in C++ (Static vs Dynamic Binding) Explained with Examples

Two concepts you will come to hear frequently when learning OOP are binding and its types: early binding, late binding, static binding, and dynamic binding . The terminology may seem technical initially, but don’t worry — we will decompose them into easy-to-understand analogies and simple code samples (C++) combined with a comparison table. What is Binding in Programming? Binding means linking a function call to the actual function definition.  Example analogy: Imagine you’re calling your friend on the phone. If you know exactly which number to dial before calling → this is early/static binding . If you just say “Call my best friend” and your phone decides at runtime who that is → this is late/dynamic binding . 1. Early Binding (Compile-time Binding / Static Binding) Function calls are resolved at compile time . The compiler already knows which function to call. Faster, but less flexible. Example (C++ Function Overloading): Here, the compiler deci...

C++ Code for Function Overriding Without virtual

Example In C++, function overriding happens when a derived class defines a function with the same name as a base class function. Unless the base class method is specified as virtual, the compiler engages in early binding (compile-time decision). This implies that the base class version will be invoked even when the pointer points to an object of the derived classes. This leads to a lack of real-time polymorphism occurring. Code Example # include < iostream > using namespace std ; class Animal { public : void sound ( ) { // Not virtual cout < < " Animal makes a sound " < < endl ; } } ; class Dog : public Animal { public : void sound ( ) { cout < < " Dog barks " < < endl ; } } ; int main ( ) { Animal * a1 ; Dog d ; a1 = & d ; a1 - > sound ( ) ; // Calls Animal's version (not Dog's) return 0 ; } Output Animal make...

C++ Code for Function Overriding Using Virtual Keyword

Example Function Overriding in OOP occurs when a derived class has its own implementation of a function which already exists in the base class. The base class virtual function should be declared and redefined in the derived class. This also allows Runtime Polymorphism where the relevant function is chosen at run time based on the type of object used. # include < iostream > using namespace std ; class Animal { public : virtual void sound ( ) { // Virtual function cout < < " Animal makes a sound " < < endl ; } } ; class Dog : public Animal { public : void sound ( ) override { // Overriding base class function cout < < " Dog barks " < < endl ; } } ; class Cat : public Animal { public : void sound ( ) override { cout < < " Cat meows " < < endl ; } } ; int main ( ) { Animal * a1 ; Dog d ; Cat c ; ...

Polymorphism in OOPs: Definition, Types, and Real-Life Examples

  What is Polymorphism in OOPs? The word Polymorphism is derived from two Greek words: Poly → many Morph → forms So, Polymorphism means having many forms. In computer programming, polymorphism refers to the property that a function, operator or object will behave differently under different circumstances . That is, the input can be different tasks done by the same name of the function. Simple Analogy : Think of the word “run” : Athletes run in a race. Programs run on a computer. Cars run on fuel. It is repetition of the same word, but the meaning is different depending on the context. This is the polymorphism of OOP. Types of Polymorphism in C++ The two most common types of polymorphism in C++ are: Compile-Time Polymorphism (Static Polymorphism) Run-Time Polymorphism (Dynamic Polymorphism) Let us get to know them by example. 1. Compile-Time Polymorphism (Static Polymorphism) This type of polymorphism is resolved at compile time . It is achieve...

C++ Code for Operator Overloading

A C++ program that demonstrates Operator Overloading for the + operator on a Complex number class. # include < iostream > using namespace std ; class Complex { int real , imag ; // Real and imaginary parts public : // Constructor with default values Complex ( int r = 0 , int i = 0 ) { real = r ; imag = i ; } // Overloading + operator Complex operator + ( Complex const & obj ) { // Add real and imaginary parts separately return Complex ( real + obj . real , imag + obj . imag ) ; } // Function to display complex number void display ( ) { cout < < real < < " + " < < imag < < " i " < < endl ; } } ; int main ( ) { Complex c1 ( 2 , 3 ) , c2 ( 4 , 5 ) ; // Calls overloaded operator+ Complex c3 = c1 + c2 ; // Display result c3 . display ( ) ; // Output: 6 + 8i return 0 ; } Output   6 + ...