Class Variables and Instance Variables in Python

Class variables and instance variables are two important concepts related to classes in Python. In this article, we will discuss class variable and instance variables with examples. We can define empty class in Python as shown below Two types of variables associated with a Python class – instance variables and class variables. Instance variables Instance … Read more

How to Concatenate Strings in Python

String concatenation is a common task in most applications. In this article, we will look into different ways to concatenate strings in Python. 1.Using the + operator To concatenate strings we can use the + operator. Output Here string str1 and str2 are joined using the + operator. We can add space between str1 and … Read more

Split Strings in C++

Splitting string into sub-strings is a common task in many applications. In this article, we will discuss various ways to split strings in C++. 1.Using the getline function The getline function can be used to split strings in C++. is : Extact string from istream object str : extracted line string delim : delimiter character … Read more

What is string::npos in C++?

In this article, we will discuss string::npos in C++. The std::string::npos is a static member constant. It is defined in the string (basic_string.h) header file. It is a static member constant with the maximum value representable by the type size_type. The type of size_type is unsigned integer however it is initialized as -1 but due … Read more

All About Pure Virtual Functions in C++

In this article, we will discuss pure virtual functions in C++ and usage with examples. Let’s dive into the definition of pure virtual function. So what is pure virtual function? A pure virtual function is a function, that must be overriden in the derived class need not to be defined A virtual function can be … Read more

Reading String From Input in C++

In this article, we will discuss different ways to read strings from input in C++. The cin object and getline function can be used to read strings. Using the cin to read string input In this example, we will use cin object to read strings. The cin is an istream object. Output Note that there … Read more

Update Software in Ubuntu

Sometimes we may need to update already installed specific software packages (Firefox, Nginx, etc) in Ubuntu. In this article, we will discuss a way to update a software package using the terminal. If we run sudo apt upgrade command it will update all the packages. We can update a specific software package by following the … Read more

Virtual Destructors in CPP

In this article, we will discuss virtual destructors in CPP. Destructor is part of Resource Acquisition Is Initialization(RAII) programming idiom. The basic idea of RAII is constructor will acquire(allocate) resources and the destructor will release resources for a class. The most common example of a destructor is when the constructor uses new, and the destructor … Read more

Size of C++ classes

In this article, we will discuss the size of C++ classes. We will look into an empty class, a class with member function, a class with virtual functions, and a class with data members. We will be using a 64-bit machine to compile the test code. For a 64-bit machine, the pointer size is 8 … Read more