TEMPLATES (plantillas)

Description

Mind Map on TEMPLATES (plantillas), created by Lot Schacht on 19/05/2016.
Lot Schacht
Mind Map by Lot Schacht, updated more than 1 year ago
Lot Schacht
Created by Lot Schacht about 8 years ago
427
0

Resource summary

TEMPLATES (plantillas)
  1. Se utilizan para declarar un tipo de dato "provisional".
    1. Se declararán variables con datos de cualquier tipo.
      1. El compilador reconocerá este tipo de dato y le dará el trato adecuado dentro del método.
        1. Así que podríamos mandar cualquier tipo de dato a esta plantilla, por ejemplo un 3.72, y el compilador comenzará a tratar a esta variable como un respectivo float.
      2. Reemplazando a int, float, char, string, etc. por un momento.
      3. Se declaran con la palabra reservada "template".
        1. template<class T>
          1. Se declara en la clase.
            1. template <class T> class mypair { T a,b; public: mypair(T first, T second) { a=first; b=second; } T getmax(); };
              1. Se vuelve a declarar antes del método donde se utilizará.
                1. template <class T> T mypair<T>::getmax () { T val; val = a>b? a : b; return val; }
                  1. En este ejemplo, cualquier tipo de valor que llegue a las variables a y b a través del first y second del constructor será tratado como tal dentro del programa.
        Show full summary Hide full summary

        Similar

        OCR GCSE Latin Vocab flash cards - all
        jess99
        I'm the king of the castle
        archita.kmr
        Spanish Vocab Flash Cards
        Clarice Thorn
        A-Level Physics: Forces
        cian.buckley+1
        French Grammar- Irregular Verbs
        thornamelia
        Roles of Education
        Isobel Wagner
        B1.1.1 Diet and Exercise Flash Cards
        Tom.Snow
        History GCSE AQA B: Modern World History - International Relations: Conflict and Peace in the 20th Century - Topic 2: Peacemaking 1918-19 and the League of Nations
        mariannakeating
        TItrations (how to do the experiment) (concentrations)
        janey.efen
        Leaving Cert Poetry 2017
        Mark O'M
        Siege bank callouts
        niklas weckerle