Category: 10. C++

  • Function Overriding in C++

    A function is a collection of code blocks with instructions inside, which is used for specific tasks. It is meant to be reused as per requirement, making the division of complex problems into smaller and manageable pieces. What is Function Overriding in C++? Function overriding is a concept of object-oriented programming which allows a derived class…

  • Function Overloading in C++

    Function overloading in C++ allows you to define multiple functions with the same name but different parameters. Function overloading is used to achieve polymorphism which is an important concept of object-oriented programming systems. Syntax for Overloaded Functions Consider the following two function declarations having the same name but different parameters − Example of Function Overloading In…

  • Return Statement in C++

    The return statement in C++ is used to exit a function and to send a value back to the function’s caller which is optional depending on requirement. It plays a very important role in controlling the flow of a program and making sure that functions will provide results to other parts of the code. Syntax Below is…

  • C++ Recursion (Recursive Function)

    Recursion is a programming technique where a function calls itself over again and again with modified arguments until it reaches its base case, where the recursion stops. It breaks a problem down into smaller, more manageable sub-problems, recursion allows for elegant and better solutions to complex problems. Recursive Function A recursive function is a function…

  • Multiple Function Parameters in C++

    C++ multiple function parameters describe the ability of a function to accept more than one argument or can say functions with multiple parameters to perform operations using several inputs, this feature makes a function to execute more complex operations by working with multiple subset of data at once. Syntax In C++, you can define a…

  • C++ Functions

    A function is a group of statements that together perform a task. Every C++ program has at least one function, which is main(), and all the most trivial programs can define additional functions. You can divide up your code into separate functions. How you divide up your code among different functions is up to you, but…

  • C++ String Concatenation

    String concatenation is the process of adding an element to an existing element. In this context, string concatenation is the method by which two (or more) strings can be added to one another. Hence, the resultant string is the combination of the initial string and the added string. There are several methods to concatenate strings…

  • C++ String Length

    Length of a string is the number of characters present in the string. These characters can be of the data type char, and these include all alphanumeric elements, symbols and miscellaneous characters. In C++ programming language, there are two types of strings- Character Arrays of C-Style type, and String objects which are built-in objects of <string> class. The length of a string also includes…

  • C++ Strings

    C++ provides following two types of string representations − 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 ‘\0’. Thus a null-terminated string contains the characters that comprise the string…

  • Unions in C++

    In C++, a union is a user-defined data type that allows you to store different data types in the same memory location. However, the union can store only one of its member variables at a time, which means that if you assign a value to one member, the previous value stored in another member is overwritten. Where the size…