Line 54 should be an error. Since total is not a static const member, it shouldn't exist without one of your class objects. Even if it is a static const member, you would have to assign a value to it first.
Even if you do that, your assumption //should print 35 that is 5 + 10 + 20 is wrong, since then you can't change total (which is now a const variable). Even assuming you could, the only place you do anything to the value of total is in your derived classes' constructors.
Also, the constructors for your derived classes do not set total equal to some value first. That means total is equal to some undefined value when you do total+=val;