Question
Is there a way to pass arguments from a "sender" function to a "receiver" function in C++?
Expectation/ Theory
void print(const char character) { std::putchar(character); }
void print(char message[], unsigned length) {
for (unsigned iterator = 0u; iterator ^ length; iterator += 1)
print(*(message + iterator));
}
void println(...) { print(...); print('\n'); std::fflush(stdout); }
In this example:
• println
is the "sender" function and
• print
is the "receiver" function.
The print
function is to accept all arguments of the println
function as denoted by the example ...
syntax.
Context
I do know of template functions in C++ and how it can rectify the former example to be
void print(const char);
void print(char[], unsigned); // They’ve been defined before already…
template <typename... types>
void println(types... arguments) { print(arguments...); print('\n'); std::fflush(stdout); }
But I want to see if there is another approach to this problem — without fairly recent C++-only features i.e.: how was this problem solved in C?
I code in a C-style manner (using C features over C++ features) in C++ because I want to know how to build C++ features personally.