I met this method declaration syntax in some C++ code :
formatted_log_t( log_level_t level, const wchar_t* msg ) : fmt(msg), level(level) {}
I don't understand how this is processed, the presence of ":", "fmt" & "level" before curly braces...
I met this method declaration syntax in some C++ code :
formatted_log_t( log_level_t level, const wchar_t* msg ) : fmt(msg), level(level) {}
I don't understand how this is processed, the presence of ":", "fmt" & "level" before curly braces...
It's the C++ Initialization list. You can use it with class constructor example
class MaClasse
{
int myInt;
MaClasse(int value) : myInt(value)
{
}
};
It is used to initialize member variable. It is faster to use the initialization list than use initialization in the body of the constructor