I created a class, SettingsClass, which contains static strings containing db connection strings that will be used by the MySQL C ++ connector library (for example, hostname, dbname, username, password).
Whenever a function needs to connect to a database, it calls the .c_str () function for these static strings. For instance:
Class SettingsClass { public: static string hostname; ... }SettingsClass; string SettingsClass::hostname;
Static lines are filled once in the process of life. Its value is read from the configuration file.
My application is multithreaded. Am I using c_str () in a safe way?
source share