Deprecated attribute in C++14 with Examples
In this article, we will discuss Deprecated attribute in C++14. Deprecated means the use of the name or entity declared with this attribute is allowed but discouraged for some reason. The compiler gives warnings and if string literals are provided, they are included in warnings.
For example, let’s consider the following program of multiplication of two numbers:
Explanation: In the above program, a multiplication operation has been performed with the help of a simple function named multiply.
Now, to tell the programmers that this approach is outdated, perform another approach by deprecating the function using the below syntax:
[[deprecated (“Write your message”)]]
Lists of what can be deprecated are as follows:
- Class, struct, union
- Non-static data member
- Template specialization