Should a class ever have static and non-static members

language-agnostic, oop

Solution

One example: when Creation has to happen in a specific way.

class Foo {
public:
  static Foo* Create(...params...);

private:
  Foo();
};

Problem

I'm trying to figure out when it would be appropriate for a class to have both static and non-static functions. AKA: ``` $obj = new ClassA; $obj->doOOPStuff(); $something = ClassA::doStaticStuff(); ``` Note: This example is done in PHP, however the question is language agnostic . It seems that if you have a class that is meant to be instantiated, any functions that can be called statically, most likely belong in another class. Is there any viable cases where I would have a class that used static AND non-static members?

Original source