That are 2 totally different things: using another iMac as a a second screen or using the optical drive of another iMac as an optical drive.
https://support.apple.com/kb/PH10644?viewlocale=en_AE&locale=en_AE tells how to connect to another Mac to use it's disk as a shared device, if you find that easier than using an external drive.
Kees
As I was told that my early 2008 imac is now considered "vintage" I chose to buy a new imac in the fall of 2014. After some research it appears that there is no easy way to use the vintage imac as a second screen, but I'm not giving up on the idea. Anyone know a way to do it? As an added bonus, I'd love to be able to use the cd/dvd drive since it's a major pain that my new imac doesn't have one (which I regret now).
I would appreciate any help! Thanks!

Chowhound
Comic Vine
GameFAQs
GameSpot
Giant Bomb
TechRepublic