I'm trying to do something that I remember having seen somewhere, though I can't remember where I saw that... I try to pass in a function an object that's not yet defined, I don't know how to explain it, but I believe it has something to do with constant casts...
I saw something like that somewhere, I know that it convert the "array" to assign it to the variables defined in the class that is kind of "casted"... As if a "foo" object was defined directly in the sent params, as you would simply do with any number constant...Code:struct foo { int a, b, c; foo(int d, int e, int f) { a = d; b = e; c = f; } }; void func(foo obj) { //Something with the "obj"... } //Under main: func( (foo){1, 2, 3} ); //Or something that'd give the same result: foo OBJ(1, 2, 3); func( OBJ );
How can I achieve to make "(foo){1, 2, 3}" works? Is it a cast, const cast, or an overloading of constructor or whatever? Because I think it may not be an overload, if you don't initially have an instance var of that structure... Or there is some concept I am mixing up... Casting "(foo)" doesn't create an instance of that structure, right?
Thanks in advance.



LinkBack URL
About LinkBacks


