Member Functions are inline by default (C++)

This tip submitted by Ash on 2005-02-05 17:19:23. It has been viewed 53420 times.
Rating of 6.0 with 233 votes



Always remeber that member functions that do not only give the prototype inside the class are inline by default, i.e. in this:
class myClass {
  public:
    int myFunction();
}

int myClass::myFunction() {
  return 1;
}

myFunction is not inline, while in this, it is:
class myClass {
  public:
    int myFunction() { return 1; }
}

It is useful to remeber this, as inline functions give a speed boost to function with only very few statements, while normal functions are good for longer, more complex function.






More tips

Help your fellow programmers! Add a tip!