0

Let's have

class ClassA
{
public:
ClassA() = delete;
ClassA(int InObjectID):ObjectID(InObjectID){};
int GetID(){return ObjectID;};
private:
const int ObjectID;
}

a. Is the function ClassA(int) inline by default?

b. Is the function GetID(void) inline by default?

Physician
  • 483
  • 2
  • 7
  • 2
    Note that while these two functions are implicitly inline, it's not because they're user-defined. It's because they're defined in the class definition. – JohnFilleau Dec 22 '21 at 14:44
  • 2
    Note that `inline` does not refer to the inlining of function calls, but to whether there can be definitions in more than one translation unit. – molbdnilo Dec 22 '21 at 14:45
  • @molbdnilo great comment. I would've asked about that specific point. – Physician Dec 22 '21 at 14:52
  • @JohnFilleau great comment. I actually asked because I found a compile error for file-scoped, header-defined functions, and not for member functions in class definition in the header. – Physician Dec 22 '21 at 14:54

1 Answers1

2

a. Is the function ClassA(int) inline by default?

b. Is the function GetID(void) inline by default?

Yes. Member functions that are defined within the class definition are implicitly inline.

eerorika
  • 232,697
  • 12
  • 197
  • 326