In my program I often need to use parameters to create log messages and to create string commands. For example:
This is not real code, but illustrate what I mean. I had to create an exception class that allows me to create error messages with parameters in a straightforward manner, using va_args. This is the constructor:
printf("Time of event %s:\nEvent: %s\n", event_time, description);
The code is not perfect, I know. I do not know how to do it better. However, the point is: is this kind of construction possible in C++? I was changing char* to string, now I can't use sprintf to format my command in one line.
Excecao::Excecao(const char* fmt, ...)
void Excecao::setStr(const char* fmt, va_list args)
vsnprintf(buffer, 1024, fmt, args);
_description = buffer;
Thanks any suggestion or comment.