It's the car number that gains the points, if it is within the same class then that does not change or alter the points, just continue. If the driver changes class say from 2 to 4 then they start to accrue points in the new class their old points remain in the previous class.
Scrutineers could call for engines from all cars that accrued points to be stripped if in a trophy winning place for restricted classes at the end of the season.