• Navigate
    • 21.x — Chapter 21 summary and quiz
    • Table of contents
    • 21.13 — Shallow vs. deep copying
  • Site Index
  • Latest Changes
  • About
    • Leave feedback
    • Report an issue
    • Contact / Support
    • Site FAQ
    • Privacy Policy
    • Donate
  •  
  • Search
Learn C++
Learn C++
Skill up with our free tutorials
Skip to content
  • Navigate
    • 21.x — Chapter 21 summary and quiz
    • Table of contents
    • 21.13 — Shallow vs. deep copying
  • Site Index
  • Latest Changes
  • About
    • Leave feedback
    • Report an issue
    • Contact / Support
    • Site FAQ
    • Privacy Policy
    • Donate
  •  
  • Search
Tag: function template

Tag: function template

21.14 — Overloading operators and function templates

219

In lesson , we discussed how the compiler will use function templates to instantiate functions, which are then compiled. We also noted that these functions may not compile, if the code in the function template tries to perform some operation that the actual type doesn’t support (such as adding integer …

Alex April 29, 2008, 8:14 pm PDT September 11, 2023
Continue reading"21.14 — Overloading operators and function templates"

11.6 — Function templates

245

Let’s say you wanted to write a function to calculate the maximum of two numbers. You might do so like this: int max(int x, int y) { return (x < y) ? y : x; // Note: we use < instead of > because std::max uses < } While the …

Alex April 18, 2008, 4:54 pm PDT January 27, 2025
Continue reading"11.6 — Function templates"

©2024 Learn C++ Privacy Policy