C++ Templates and Generics Functions

Поділитися
Вставка
  • Опубліковано 21 кві 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 22 дні тому

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

    • @KennyYipCoding
      @KennyYipCoding  22 дні тому +1

      Yes! The type would just be vector then

    • @badwolf9956
      @badwolf9956 22 дні тому

      @@KennyYipCoding Oh cool! Thanks