Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Multiple Typenames | Creating First Template
C++ Templates
course content

Contenido del Curso

C++ Templates

C++ Templates

1. Creating First Template
2. Templates Usage
3. Class Templates
4. Template Specialization

bookMultiple Typenames

Sometimes you will need more than one type to use in the function, and for this you can simply add more template parameters. Just make sure you give them different names.

Note

There is no inherent limit to the number of template parameters. However, as a general guideline keep the number of them as low as possible.

Create the function template print_pair that allows you to output a formatted message containing a pair of values. By defining the template parameters, you can specify the types of the two values you want to print.

Tarea

Create and call a template with multiple type parameters.

  1. Fill in the ___ to complete the template definition.
  2. Call the template twice:
    • First call: Use <int, std::string> as the template types.
    • Second call: Use <char, float> as the template types.

Switch to desktopCambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 1. Capítulo 4
toggle bottom row

bookMultiple Typenames

Sometimes you will need more than one type to use in the function, and for this you can simply add more template parameters. Just make sure you give them different names.

Note

There is no inherent limit to the number of template parameters. However, as a general guideline keep the number of them as low as possible.

Create the function template print_pair that allows you to output a formatted message containing a pair of values. By defining the template parameters, you can specify the types of the two values you want to print.

Tarea

Create and call a template with multiple type parameters.

  1. Fill in the ___ to complete the template definition.
  2. Call the template twice:
    • First call: Use <int, std::string> as the template types.
    • Second call: Use <char, float> as the template types.

Switch to desktopCambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 1. Capítulo 4
toggle bottom row

bookMultiple Typenames

Sometimes you will need more than one type to use in the function, and for this you can simply add more template parameters. Just make sure you give them different names.

Note

There is no inherent limit to the number of template parameters. However, as a general guideline keep the number of them as low as possible.

Create the function template print_pair that allows you to output a formatted message containing a pair of values. By defining the template parameters, you can specify the types of the two values you want to print.

Tarea

Create and call a template with multiple type parameters.

  1. Fill in the ___ to complete the template definition.
  2. Call the template twice:
    • First call: Use <int, std::string> as the template types.
    • Second call: Use <char, float> as the template types.

Switch to desktopCambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sometimes you will need more than one type to use in the function, and for this you can simply add more template parameters. Just make sure you give them different names.

Note

There is no inherent limit to the number of template parameters. However, as a general guideline keep the number of them as low as possible.

Create the function template print_pair that allows you to output a formatted message containing a pair of values. By defining the template parameters, you can specify the types of the two values you want to print.

Tarea

Create and call a template with multiple type parameters.

  1. Fill in the ___ to complete the template definition.
  2. Call the template twice:
    • First call: Use <int, std::string> as the template types.
    • Second call: Use <char, float> as the template types.

Switch to desktopCambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
Sección 1. Capítulo 4
Switch to desktopCambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
some-alt