Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Typename Naming Conventions | Creating First Template
C++ Templates
course content

Зміст курсу

C++ Templates

C++ Templates

1. Creating First Template
2. Templates Usage
3. Template Specialization
4. Class
5. Template Metaprogramming

Typename Naming Conventions

Just like the variable you can name templates parameters anything as you want and just like the common variables naming there are some bad and good practice.

h

good_naming_example

h

bad_naming_example

copy
12345
template<typename T> void myTemplate() { // Function implementation }

You might think why the second one is considered a bad example as it is clearer and easier to understand. The answer is simple. Using T as a placeholder for template type parameters is a convention. It stands for Type and is commonly used to indicate that the template parameter represents a type.

Note

Sometimes when there are multiple parameters and the use is not immediately obvious then you can use descriptive names prefixed with T

Все було зрозуміло?

Секція 1. Розділ 5
We're sorry to hear that something went wrong. What happened?
some-alt