Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: C++
Expertise: Beginner
Aug 29, 2000

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.

Danny Kalev
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap