Non-static member functions

Non-static member functions

A non-static member function is a function that is declared in a member specification of a class without a static or friend specifier.

class S {
    int mf1(); // non-static member function declaration
    void mf2() volatile, mf3() &&; // can be cv-qualified and reference-qualified
    int mf4() const { return data; } // can be defined inline
    virtual void mf5() final; // can be virtual, can use final/override
    S() : data(12) {} // constructors are member functions too
    int data;
};
int S::mf1() { return 7; } // if not defined inline, has to be defined at namespace

Any 登录查看完整内容