As far as I know this never actually happened although presents an interesting situation. What they would have done would probably depended heavily upon the realm, time, stability and characters involved. It is a somewhat unlikely event though and one that probably isn't worth the scripting.
A more modern but perhaps plausible example: Alfonso XIII of Spain, the grandfather of the current king, was proclaimed king upon his birth on May 17, 1886; his father Alfonso XII died November 1885 while his wife Maria Cristina was three months pregnant. If her third child was a girl, the throne would pass to her elder daughter, but if it was a boy, he would be king at birth. The queen ruled as regent during her pregnancy, and then up until Alfonso turned 16.