C++ Templates and Generics Functions

Поделиться
HTML-код
  • Опубликовано: 5 дек 2024
  • Generics and Templates in C++. In this video you will learn how to create templates so that your functions can work for any type, hence the term generic. Two examples where we would want to create a generic function would be if we were swapping two variables or iterating and printing out the values of a vector. In both cases, there is no need to specify a type so we can just use a template to create a generic type name.
    If you need to review these topics:
    Functions: • C++ Functions
    Pass by Value vs Reference: • C++ Functions Pass by ...
    Function Overloading: • C++ Function Overloading
    Const Reference: • C++ Const Reference
    C++ Playlist:
    • C++ Programming Tutorial
    Install C++ with VS Code:
    • How to set up C++ in V...
    Subscribe for more coding tutorials 😄!

Комментарии • 3

  • @badwolf9956
    @badwolf9956 6 месяцев назад +1

    Would it be possible to use a template function to print out a 2D vector?

    • @KennyYipCoding
      @KennyYipCoding  6 месяцев назад +2

      Yes! The type would just be vector then

    • @badwolf9956
      @badwolf9956 6 месяцев назад +1

      @@KennyYipCoding Oh cool! Thanks