简体   繁体   中英

Usage of Inline for constructors and Destructors in C++

I am new to C++.I was told not to use Inline with Constructors(containing user defined datatypes as arguments) and destructors.

Is there any such thing in C++?

I think it is fine to use Inline for constructors and destructors as long as they are short and simple(not complicated).

Can someone help me out.An example would help.Thanks.

There is no rules like that. inline is nothing more than a hint to the compiler and it can do whatever it wants on it.

Note that methods define in the class declaration are implicitly inline, and modern compiler support link time optimisation to allow inlining cross multiple compilation unit…

So give the hint on what you think is right like short functions or constructors and trust your compiler to do what is best, it will be right at 99.9%

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM