Depending on the content of the contract, you can get such an agreement. A normal contract would specify that the whole of the code belongs to the hiring company. However, you can specify that no part of the code can be reused elsewhere. I have signed such agreements in the past, and while I don't like the clause, I just charge a little extra for that factor.
Put another way, I'm not out looking to take code from clients and make money off it. I'm out to reduce my own workload. So if I develop a neat utility class as part of a project for one client, I would want to be able to reuse that utility in my next project that needs it. This isn't taking proprietary ideas or anything like that, just saving me from rewriting the same class again.
From the client's perspective, reusing code like that shouldn't make a difference (and in fact, when I discussed the issue with one client, we modified the clause to allow me to reuse code that was not based off any proprietary information given to me by the client). If you really want to make sure nothing gets reused, add in the clause, but be prepared for some questions about it.