starkk92
starkk92

Reputation: 5924

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.

Upvotes: 1

Views: 325

Answers (1)

galop1n
galop1n

Reputation: 8824

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%

Upvotes: 3

Related Questions