...i mistakenly inserted camera cable in wrong side.The pi suddenly restarted ...
Am I to understand that you were plugging the camera cable in whilst the Pi was powered up and running? One should never connect and disconnect things like that when power is applied. Power down, connect thing, check connections, check connections again, power up. I would not expect this to have killed your Pi though, perhaps something else got shorted out as you were doing that.
Or, am I to understand that you were plugging the camera cable in whilst the Pi was powered down, but as you connected the cable it 'suddenly started'. If so something else was definitely going on as you connected the camera. The camera cannot power up a Pi by itself.
What exactly did you do?
Memory in C++ is a leaky abstraction .