Function Templates | C++ Tutorial

Sdílet
Vložit
  • čas přidán 26. 04. 2022
  • How to use function templates in C++ to reduce code duplication. Source code: github.com/portfoliocourses/c.... Check out www.portfoliocourses.com to build a portfolio that will impress employers!

Komentáře • 23

  • @t01
    @t01 Před 2 lety +6

    Thank you. This gotta be the highest quality and most in-depth C/C++ content around!

  • @valentinsimeonov1296
    @valentinsimeonov1296 Před rokem +2

    Thank you! You explained this concept way better than the learning materials provided by my school

  • @stepsvideos
    @stepsvideos Před rokem

    I learn something new, about C++, every few years. Maybe it's because it's only every few years that someone comes along, and shows you that the C++ feature that you may have heard about and shied away from, is not a Pandora's box full of icky things, but something simple and very useful. Many thanks.

  • @ecmrn
    @ecmrn Před 6 měsíci +1

    Such good explanations!

  • @XharkXlayer
    @XharkXlayer Před 5 měsíci

    God bless you for your programming tutorials! you have been a ton of help in my academic and professional career!

    • @PortfolioCourses
      @PortfolioCourses  Před 5 měsíci

      I'm so glad to hear that these tutorials have helped you out! :-D

  • @death2theworld
    @death2theworld Před rokem +1

    This is a really good explanation thank you

  • @-alaa5292
    @-alaa5292 Před rokem +1

    Thank you.
    Really good and helpful explaination.

  • @mikexue5104
    @mikexue5104 Před 10 měsíci

    what if all parameters and return value with different type? say, divide(double a, int b) {return "result is " + a/b; }.
    how to define the template function?

  • @johnibat
    @johnibat Před rokem +1

    Thank you... very useful...🙏

    • @PortfolioCourses
      @PortfolioCourses  Před rokem

      You're welcome, I'm happy that you found the video useful! :-)

  • @peterwan1808
    @peterwan1808 Před rokem +1

    Thank you for posting! If possible, could you provide an explanation as to why a function template definition should be put inside a header file (as opposed to keeping the implementation of the function template in a .cpp file and the prototype of the template in a .h file like normal functions) ?

    • @PortfolioCourses
      @PortfolioCourses  Před rokem +1

      Placing the function template definition in the header file allows it to be defined before it is used anywhere, from the perspective of the compiler that is reading your program source code, which can allow the compiler to better optimize the code. This link describes the issue: www.bogotobogo.com/cplusplus/template_declaration_definition_header_implementation_file.php. 🙂

    • @peterwan1808
      @peterwan1808 Před rokem

      @@PortfolioCourses This is exactly what I was looking for - thank you!

    • @PortfolioCourses
      @PortfolioCourses  Před rokem

      @@peterwan1808 You're welcome! 🙂

  • @Victor-fl8ex
    @Victor-fl8ex Před 2 lety +1

    Hey Kevin. I hope you doing well ! Nice video once again. I would like to contact you somehow to ask something about some code of mine. Its pretty light, is there any chance I can reach you?

    • @PortfolioCourses
      @PortfolioCourses  Před 2 lety +1

      Right now between my day job, making videos for this channel, and my family, I won't be able to get into helping people over e-mail or something like that. In the future I am hoping to setup some kind of 1-on-1 tutoring option, but for right now I can't yet.

    • @Victor-fl8ex
      @Victor-fl8ex Před 2 lety

      @@PortfolioCourses fair enough. Thanks for taking your time to answer back!