On Thu, 03 Jun 2010, 15:55:20 +0200, Roger Oberholtzer wrote:
On Thu, 2010-06-03 at 14:01 +0200, Per Jessen wrote:
G T Smith wrote:
I think I have come across a couple of references suggesting that an object constructor could supply equivalent functionality.
There's no doubt it could, but I think the key thing would be to have the same syntax for C and C++ (in this respect) and to allow C code adhering to C99 to be compiled with g++.
Exactly!
What would be the equivalent functionality in g++? I am not a c++ programmer, so a concrete example is needed!
The C version of one use is this:
typedef struct {
const char *CMD_SERVICE, *CMD_TRANSPORT;
} dPavueCnfg;
dPavueCnfg dConfig = {
.CMD_SERVICE = "DPcmd", .CMD_TRANSPORT = "tcp" };
What would I do in C++?
The same you would have done in C before C99: dPavueCnfg dConfig = { "DPcmd", "tcp" }; I.e. ensure the initializers match the same position their respective struct elements have! Using the names of the struct tags makes it much more easy to avoid errors, but this is apparently something the C++ standardization people haven't though about (yet) ;-) HTH, cheers. l8er manfred -- To unsubscribe, e-mail: opensuse-programming+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-programming+help@opensuse.org