The above figure shows the logical function of a many-to-one switch in 2 different state. In the left figure, the switch directs the top-most input to the output, and in the second, it directs the 3rd input to the output.
One example is the switch in a boom box that let you select from CD, radio, and cassete.
Schematically (functionally), a multiplexor looks like this:
Examples:
void MyMux ( const SD &sd, const Signal &in, const Signal &out)
{
...
}
It works, but the control signals and data signals are mixed together as in[] and you have a hard time remembering how each input signal is used.
void MyMux ( const SD &sd, const Signal &c, const Signal &in, const Signal &out)
{
...
}
Notice that the method has 2 different set of input signals: c[] and in[].
The control signals and data signals are separated and you have much a easier time remembering how each input signal is used.
You invoke the MyMux with 4 parameters:
/* =======================================================
You need to pass the control signals and input signals
as different parameters
======================================================= */
MyMux ( "1b-4d", (co1, co0), (in3, in2, in1, in0), out );
// ^^^ ^^^
// Pass in the control and input signals separately
Mux ( "ab-db", (sw7,sw8), (sw3,sw2,sw1,sw0), out );
(which is identical to the second example).