I see a few problems:
-You lack a semicolon on the line that is bad; C generally prefers semicolons (although I suspect you did not copy-paste the code, but rather re-typed it)
-You are assigning 4 buttons to toggle the state of 4 pistons when pressed (yes?), however, it appears as though the If will run every cycle that the button is pressed (constantly inverting/setting the piston while the button is held), you would need a check to see if the button is pressed but wasn't last iteration.
-Is there any need for states and prestates? Couldn't you just say
Code:
state[b] = !state[b]; solenoid[b]->set(state[b]);
and get the same result?
-What are you doing where you need an array of solenoids? In embedded programming such as FRC robots, I've always hated working with arrays of objects, as most objects we use have a specific purpose and are handled in different ways (depending on the subsystem they operate under, for example), and usually robots are simple enough where having a few references isn't a bad or messy thing.