Practice mode C++

In modern C++, what is the main language-level guarantee of declaring a function inline?

Correct answer A. It may be defined in several translation units without violating the one-definition rule

Explanation

inline is now chiefly a linkage rule: an inline function may be defined identically in multiple translation units, typically by placing it in a header, without causing duplicate-definition linker errors. Whether calls are actually expanded in place is entirely the optimiser's decision, and compilers often inline non-inline functions or ignore the hint. Inline functions can still have their address taken.

Report a problem

Answer checked How we write and check questions

Tip: press A, B, C or D to answer, and N for the next question.

Advertisement

Have a question about this answer?

Your email address will not be published. Required fields are marked *

Links and website addresses are not allowed in comments.