I got this idea for hack but im just started learning c++ so i cant make it myself.

but basiclt the idea is that you can through a c4 and when a enemy get into the field of the c4s explosive ratio it auto detonate, so my question is this possible and
if (possible = true) compile a version of this?