g*********s 发帖数: 1782 | 1 // this is a .h file
class X {
};
inline X::X()
{
cout << "X" << endl;
}
1) is "inline" keyword required or optional here?
2) will compiler always "inline" this function if "inline" keyword exists?
3) will compiler always skip "inline" this function if "inline" keyword
doesn't exists?
4) if 2) & 3) both "no", then why we need inline keyword? | t****t 发帖数: 6806 | 2 1. if multiple source will include this .h, then inline is required.
otherwise it's multiple definition. inline members can be multiple defined,
even if it is not always inlined.
2. no
3. no
4. see answer to 1.
【在 g*********s 的大作中提到】 : // this is a .h file : class X { : }; : inline X::X() : { : cout << "X" << endl; : } : 1) is "inline" keyword required or optional here? : 2) will compiler always "inline" this function if "inline" keyword exists? : 3) will compiler always skip "inline" this function if "inline" keyword
|
|