if someone is going to get a B747-300 type rating (if there is such thing), at the completion, they will automatically have a B747 class endorsement and is allowed to fly the other B747-200, B747SP, etc. correct?
When someone qualifies for the 300 type rating as described by the company Training and Checking procedures, they have the appropriate
type or
class endorsement entered into their logbook. In this case, it would be the B747 class endorsement as described above. The training usually refers to a specific type.
The class endorsement is the legal requirement to fly all types included in the class but you would still need to satisfy company training and checking requirements before actually operating on various types within the class.
The aeroplanes included in a particular class probably vary from country to country.
and what about B747-400 type rating? with that, does it allow people to fly other B747-400ER, -400D, -400F etc
In Oz, the B747-400 type endorsement covers B747 Series 400 aeroplanes, all models and variants.