c++ - static method or non-static method using static field -
i have static const std::vector<sometype>
field in class. have 2 private
methods uses field (searching methods). not use members of class. should define static
or normal methods?
what should prefer? advantages/disadvantages?
methods reference static members should defined static. lets access these methods without creating instance of class, , access them static context (e.g. non-member function).
the exception rule when need make access member function defined virtual. in case have no option make function static, because static functions cannot override virtual functions.
Comments
Post a Comment