C++ 23 · Classes, memory and templates
Write a function template
One function that works for any type that supports >.
template <typename T>
T max_of(T a, T b) {
return a > b ? a : b;
}
More classes, memory and templates commands
- Define a class
- Use polymorphism
- Own an object with unique_ptr
- Share ownership with shared_ptr
- Move instead of copy
- Lock a mutex safely
All classes, memory and templates commands · C++ 23 cheatsheet