HomeChallengesRepsProblemsLeaderboardTake a challenge

Build the v-table by hand

Get the Julian answers again — with virtual, override, abstract and new all banned. Build what the compiler builds for you: a table of functions per class, a pointer to it in every object, and a call that looks the method up at run time.

Advanced25 min on the clock5 graded checks · 100 pointsObjects That VaryPro
Graded by reading your code against the checklist below.

What you build

  • Declare one static readonly table per class: slot 0 GetSchoolDate, slot 1 IsLeap, slot 2 GetSchoolBirthday
  • Give every SchoolCalendar a private field pointing at its class’s table
  • Route both leap checks in GetSchoolBirthday through Call(this, 1, year)
  • Build the Julian table from base slots 0 and 2 plus its own slot 1
  • Make sure a Julian object ends up pointing at the Julian table

Done means

Static tables, one per class; a table pointer per object; every leap check dispatched through slot 1; and none of the four keywords.

How it is graded

Published in full, before you start — every point is one of these and there is nothing else.

  1. Both leap checks go through slot 1+30Which method actually runs
  2. No virtual, override, abstract or new modifier+15Which method actually runs
  3. One static table per class; each object holds a reference+20Which method actually runs
  4. The Julian table reuses base slots 0 and 2+15Which method actually runs
  5. The base constructor never overwrites the derived table+20Which method actually runs

What it teaches

The rest of Objects That Vary