Monday, February 23, 2009

Member Functions are inline by default (C++)

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.
Author : Ash

0 nhận xét:

Post a Comment