Puedes seguirnos en

BUSCADOR

Engineering

Expand your functions in line

There is an important feature in C++, called as inline function. These functions are commonly used with classes.

Inline function are short functions which are not actually called, rather, their code in expanded in line when they are invoked. To make a function inline just precede it with the keyword inline, this way the function will get expanded inline at the point of invocation.

EXAMPLE


#include<iostream.h>
using namespace std;


inline int max(int a, int b)
{
return a>b ? a: b;
}

int main()
{
cout<<( 10>20 ? 10 : 20);
cout<< » «<< (99>88 ? 99 : 88);
return 0;
}

Anuncio publicitario

 

The reason that inline functions are so important in C++ because they allow you to create a more efficient code.
Classes require several executed interface functions, the efficiency of these functions is of great concern.

Escrito por

Administrador de ENGGDRCAOS. Canal dedicado especialmente a la formación del estudiante que aspira a ser ingeniero. Todos los videos son Ingles. Apasionado del universo Apple, estudiante de Ingeniería y Gamer por vocación.

Publicidad

ARTÍCULOS RELACIONADOS

Engineering

Function prototyping is one of the key improvements added to the C++ functions. When a function call is encountered, the compiler checks the function...

Engineering

If we want two computers to communicate over a network, then the protocols on each layer of OSI model in the sending computer should...

Engineering

Destructors is used to destroy the objects that have been created by a constructor. The destructor is member function whose name is the same...

Engineering

Inheritance is not just simply about creating various derived classes trough a base class. There are some other benefits of using Inheritance in Object...