Static data members and static member functions in C++ classes are shared by all objects of that class. Static data members are initialized to zero when the first object is created and shared across all instances, while static member functions can only access other static members and are called using the class name and scope resolution operator. The example program demonstrates a class with a static data member "count" that is incremented and accessed by multiple objects to assign increasing code values, and a static member function "showcount" that prints the shared count value.