Advertisement
Mastercpp

Ejemplo basico de plantillas de c++

Sep 11th, 2015
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.45 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. template<class T>
  5. T retornar_valores(T x ){
  6.     return x;
  7. }
  8. // podemos retorna cualquier tipos de valores
  9. // sin necesidad de escribir y copiar la funcion
  10. /* otra vez   A esto se le llama plantilla
  11.     Esto nos ahorra este codigos :
  12.    
  13.     int retornar_valores(int x){return x;}
  14.     string retornar_valores(string nombre){return nombre;}
  15.    
  16. */
  17. int main(){
  18.    
  19.     cout << retornar_valores('a') <<endl;
  20.    
  21.     return 0;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement