MIMO Functions - Examples

Hello,

Are there any good examples that anybody would recommend for multi-input multi-output functions? I have found many but, the more I look at the better.

Thank you. :)

I don't understand what you mean by "MIMO function." Software-wise, functions can easily have more than one input ("func(a, b, c)") and multiple outputs are usually handled by using either pointers to the individual return arguments, or to a structure containing multiple elements: "status = scanf(format, &a, &b, &c);" (and scanf might be a good example to look at), or "read_userdata(string, userDataP);"

Yes, I was looking for examples of functions that take multiple inputs and has multiple outputs via pointers to a container that that has multiple slots. Sorry for my noob-combination-rusty-ness. Thank you.

For most applications, the "correct" way to do that would be to define a class for the "container", and pas a reference to that class as an argument to any classes or functions that need to use that data. Pointers (to anything other than an instance of an object) should rarely be needed when writing proper c++ code.

Regards, Ray L.

In a C++ program, is it considered more correct to pass a pointer to a container:

  myfunction(&object);
:
void myfunction(myobjtect_type *o) { ... }

or to use a reference in the function:

  myfunction(object);
:
voide myfunction(myobject_type& o) { ... }

?? I'm always a bit uncomfortable with the latter, since I have this deep rooted belief that a programmer should be able to be certain that "foo(x)" won't modify x (especially for simple types), but perhaps I'm merely "thinking like a C programmer."

westfw: In a C++ program, is it considered more correct to pass a pointer to a container:

  myfunction(&object);
:
void myfunction(myobjtect_type *o) { ... }

or to use a reference in the function:

  myfunction(object);
:
voide myfunction(myobject_type& o) { ... }

?? I'm always a bit uncomfortable with the latter, since I have this deep rooted belief that a programmer should be able to be certain that "foo(x)" won't modify x (especially for simple types), but perhaps I'm merely "thinking like a C programmer."

Why would one make you "uncomfortable", and not the other. Functionally, they are essentially identical. Reference operands are simply syntactic "candy" to make pointers easier to use. Anything you can do with one, you can do just as well with the other, just with uglier syntax.

Regards, Ray L.

If I pass "foo", I expect foo to be unmodifed. if I pass "&foo", then that's explicit permission to modify foo. If the function says &foo and modifies foo, it's essentially going behind my back. (As I said, this is more disconcerting with simple types, and if you're not paying attention to the documentation. If you're calling "modify_foo(foo)", then clearly you expect it to modify the argument...)