In C++, member functions get executed in the context of an object. And a special pointer, this, holds the address of that object. We can return the address (pointer), reference or a copy of that object using the this pointer from a member function of a class. Returning the Object Pointer Here the getPointer() function … Continue reading “Returning the ‘this’ Pointer from a Member Function”
Category: Python
Python | Capture Ctr+C (SIGINT)
Some programs are meant to run for indefinite amount of time. They don’t stop by themselves. Operators generally stop then for maintenance. Most common way to stop these types of programs is by pressing Ctr+C if the program is running in foreground or by sending SIGINT signal. Here is a simple Python program that does … Continue reading “Python | Capture Ctr+C (SIGINT)”
Python | Periodic Task
Doing a periodic task is a basic programming requirement. We need it in time of implementing watchdogs, checking health of some system, sending status periodically, updating database, doing periodic backup etc. Using Loops When it comes to do something periodically, the first that comes to our mind is the ‘loop‘. First we’ll see how we … Continue reading “Python | Periodic Task”
Python | Check Whether a String is Palindrome
Palindrome string is a string that reads same from both directions – forward and backward. For example, the string, ‘ROTOR‘, is a palindrome because it reads same from both forward and backward directions. Whereas ‘MOTOR’ is not a palindrome because it does not read same from both directions. Check Palindrome by Reversing the String For … Continue reading “Python | Check Whether a String is Palindrome”
Python | Find a Substring
We can check whether a substring is present in a string using the Python find() function. If the find() function returns 0 or a positive number, the substring is present. The system of find() function. substring: The substring to be searched. start: Starting index of the range where the substring will be searched. Default value … Continue reading “Python | Find a Substring”