I did a module on c++ at university. It definitely isn't just memorisation. It's a language that you use as a tool for solving problems and designing other complex stuff at more advanced levels. Once you know it, it's quite hard to forget. Ok you can make little errors, but you'll never easily forget the general process for doing what you want. So nope it isn't a memory thing. I think programming is something you just have to do, and by doing it it just sinks in and that's it.
Oh and I think the best programmers are self-taught. The module I did was fine but so fucking boring. It's only interesting if you can go at your own pace and play around with new things as you learn them. In the form of a university module, you get herded along too fast and it's a little overwhelming. My lecturer was definitely self-taught, as were the guys who did best in the class (they just took the module to get a more 'rounded' grip on what they knew).