On Sun, Mar 27, 2011 at 4:06 AM, Clemens <clemens.zeidler@xxxxxxxxxxxxxx>wrote: > Hi, > > just try to make the ps2 bus manager c++. Is there something in c++ similar > to: > > ps2_dev ps2_device[PS2_DEVICE_COUNT] = { > { > .name = "input/mouse/ps2/0", > .active = false, > .idx = 0, > .result_sem = -1, > .command = standard_command_timeout > } > }; > You should be able to do something like this: ps2_dev ps2_device[PS2_DEVICE_COUNT] = { ps2DevBuilder("input/mouse/ps2/0") .active(false) .idx(0) .result_sem(-1) .command(standard_command_timeout) , ps2DevBuilder() //... etc. } Just have the ps2DevBuilder methods return a reference to 'this', and provide an 'operator ps2_dev()' method. This also allows you to have defaults for all your values. This is called the 'Named Parameter Idiom' and you can read about it here: http://www.parashift.com/c++-faq-lite/ctors.html#faq-10.20 Hope that helps :) --Alex