devxlogo

Avoid Redundant Inline Declarations

Avoid Redundant Inline Declarations

Remember that functions defined inside the class definition are implicitly inline. Therefore, the inline keyword is redundant in the definition of the member function of the following class:

 class Employee{public: inline const string& name() const {return _name;}private string _name;};

The inline specifier is innocuous in this example. However, it can become a maintenance problem if you move the definition of name() outside the class and extend it with more functionality (for example, if you convert the string to uppercase before returning it to the caller). You are likely to forget that the member function is still declared inline, although it shouldn’t be.

See also  How HealthStream Learning Center Supports Healthcare Education and Compliance
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist