Category Archives: OOP with C++

20. Handling Exceptions

An exception is a problem that arises during the execution of a program. A C++ exception is a response to an exceptional circumstance that arises while a program is running, such as an attempt to divide by zero. Exceptions provide a way to transfer control from one part of a program to another. C++ exception… Read More »

19. Math functions

C++ has many functions that allow you to perform mathematical tasks on numbers. C++ offers some basic math functions and the required header file to use these functions is <math.h. Mathematical calculations can be done in C++ programming language using the mathematical functions which are included in math or cmath library. These mathematical functions are defined to… Read More »

18. Strings

C++ provides following two types of string representations − The C-style character string. The string class type introduced with Standard C++. The C-Style Character String The C-style character string originated within the C language and continues to be supported within C++. This string is actually a one-dimensional array of characters which is terminated by a null character… Read More »

17. Return Array from Functions

C++ does not allow to return of an entire array as an argument to a function. However, you can return a pointer to an array by specifying the array’s name without an index. If you want to return a single-dimension array from a function, you would have to declare a function returning a pointer as… Read More »

16. Passing Arrays to Functions

C++ does not allow passing an entire array as an argument to a function. However, You can pass a pointer to an array by specifying the array’s name without an index. If you want to pass a single-dimension array as an argument in a function, you would have to declare function formal parameter in one… Read More »

15. Pointer to an Array

It is most likely that you would not understand this chapter until you go through the chapter related to C++ Pointers. So assuming you have bit understanding on pointers in C++, let us start: An array name is a constant pointer to the first element of the array. Therefore, in the declaration − double balance[50];… Read More »

14. Multi-dimensional Arrays

C++ allows multidimensional arrays. Here is the general form of a multidimensional array declaration− type name[size1][size2]…[sizeN]; For example, the following declaration creates a three dimensional 5 . 10 . 4 integer array − int threedim[5][10][4]; Two-Dimensional Arrays The simplest form of the multidimensional array is the two-dimensional array. A two-dimensional array is, in essence, a… Read More »

13. Arrays

C++ provides a data structure, the array, which stores a fixed-size sequential collection of elements of the same type. An array is used to store a collection of data, but it is often more useful to think of an array as a collection of variables of the same type. Instead of declaring individual variables, such as… Read More »

12. Memory management

What is Memory Management? Memory management is a process of managing computer memory, assigning the memory space to the programs to improve the overall system performance. Why is memory management required? As we know that arrays store homogeneous data, so most of the time, memory is allocated to the array at the declaration time. Sometimes… Read More »

11. Pointers

C++ pointers are easy and fun to learn. Some C++ tasks are performed more easily with pointers, and other C++ tasks, such as dynamic memory allocation, cannot be performed without them. What are Pointers? A pointer is a variable whose value is the address of another variable. Like any variable or constant, you must declare a pointer… Read More »