class functions
{
int addnum(int x,int y) {return (x - y)};
}
is the last part of addnum function inline ?
Printable View
class functions
{
int addnum(int x,int y) {return (x - y)};
}
is the last part of addnum function inline ?
Yes since you've given it a definition. However, you should give it the inline keyword as well (inline int addnum(...) { ... }).
arent all functions that are in classes inline by default?
No, only those that have the definition inside the class body and those that have the explicit inline keyword in the definition.
Parksie: inline inside a class?
Huh? :confused:
I mean, I've never heard of the keyword inline being used inside the class declaration.
I thought it was supposed to be given for anything that you wanted the compiler to inline.
Not that VC++ takes any notice of the inline keyword, and many other compilers probably ignore it as well.
It says in "The A.R.M." ( The Annotated C++ Reference Manual ) that methods defined inside the class declaration are equivalent to a method which uses the inline keyword.
I guess my point is that it is not just a VC++ thing.
I think the ARM predates the C++ Standard.
Either way, a superfluous inline doesn't hurt and makes it easy for the reader :D