Member function with static linkage

前端 未结 2 968
一个人的身影
一个人的身影 2020-12-08 03:56

I\'m trying to understand why the following is an error:

class Foobar {
 public:
  static void do_something();
};

static void Foobar::do_something() {} // E         


        
2条回答
  •  猫巷女王i
    2020-12-08 04:41

    This question is already well answered. Details for static can be read here

    Golden Rule: The static keyword is only used with the declaration of a static member, inside the class definition, but not with the definition of that static member.

提交回复
热议问题