It's not too easy to use public transport to cross through Namibia into Angola and then further north.
That means that, from South Africa, it's more convenient to travel through the east side of the continent. Your first hurdle will be crossing into Tanzania, as public transport between Zambia/Malawi/Mozambique and Tanzania is limited. But, the TAZARA, the train running between Zambia and Tanzania still runs, so that's perhaps your best bet for getting into Tanzania.
Public transport into the DRC from Uganda is, as far as I'm aware, virtually non-existent (and with the current situation in relation to ebola, not a wise path to take). Somalia also isn't a great destination, while traveling through South Sudan and then Sudan would need to be done with very few options for public transport.
Last I checked, Kenya to Ethiopia is also hard. There is some public transport, but you might have to resort to finding your own ride.
That still leaves crossing Sudan to get to Egypt. From Egypt's border with Sudan, you'll be fine to reach the Mediterranean coast, but, getting from Ethiopia, perhaps via Eritrea, then Sudan, will be time consuming, but, not impossible.