Category: C++

Inline Functions in C++

In this article, we will learn about inline functions, its working and how it is different than normal function in C++. liveoncode Inline function is function from which compiler copies code into calling function directly rather than branching to the called function. Since there is no branching and code is directly inserted it eliminates the

Functions in C++

In this tutorial, we will lean about function, its declaration, calls with example. Functions break large computing tasks into smaller ones, and enable people to build on what others have done instead of starting over from scratch. Structure of function in C++ //Structure of C++ program #include <iostream> using namespace std; return_type function_name(parameter_list); //function prototype

Destructors in C++

In this tutorial, we will learn about the destructors, its difference from constructor with example. fig: constructor and destructor in c++ We have a case where if object of class in created then the constructor get called automatically. Similarly there is also case when object of class is destroyed function get called automatically. Such functions are

Constructors in C++

In this tutorial, we will learn about the constructors in C++ and its types with example in detail. Constructor is the member function that is executed automatically when and object is created. Constructors is used for initializing objects as it will be called once the object is created without need of calling separate member function

Object and Class in C++

In this tutorial, we will learn about the Object and Class in C++, how to write simple class. A Simple Class Syntax of class class student //define a class { private: int roll; //class data public: void setdata(int number) //member function to set data { roll = number; } void showdata() //member function to display

goto statement in C++

We will learn about goto statement in C programming and how this statement alters the sequential flow of the program execution. goto statement Syntax of got statement: goto label; ... .. ... ... .. ... ... .. ... label: statement; Here, label indicates the location. goto tells the program to jump the code to the

Switch case statement in C++

We will learn to use switch case statement in C programming. After completing this tutorial you will be able to use switch case in almost any scenario. If we need to choose option using only single value or constant then we use switch statement.  Syntax of switch statement: switch (constant) ​{ case value1: // code

While and do while loop in C++

In this tutorial, we will learn how to execute statements repeatedly using ‘while and do while loop in C++’ , there difference and how and where to use them with examples. There may be a condition in where you  will need to execute a block of statement multiple times. Executing the same block of statement multiple time

for loop in C++

In this tutorial, we will learn how to execute statements repeatedly using for loop with examples. There may be a condition in which you need to execute a block of statement multiple times. Executing the same block of statement multiple time is called loop.  Syntax of for loop: for (initialization; test_condition; increment or decrement) { //block of