Set on/off light using c++

Hey,
I want to make a lamp, which is turning on and off pressing “E” on keyboard.
I want to use only c++. Can You give me some tips or function,which i can start make this functionally?