Virtual Functions

  • + 1 comment

    The default initialization of an int is zero, so they are incrementing the static count prior to the assignment. This will yield 1 for the first object created. If you wanted to explicitly initialize a static data member, it would be defined outside of the class, e.g.:

    int Student::student_id = 0;

    Normally, the static members would be declared in the header file, and initialized similar to the above at the top of the implementation file.