'Initialize member string with class object name in C++?
Is there a way to instantiate an object and have a string member take the object's name? I would also not mind for a gcc builtin.
Here's an example:
#include <string>
class A
{
std::string obj_name_ = /* set to the objects name (very_descriptive_name) somehow */ ;
};
A very_descriptive_name; // naming the *object* should be enough, do we really have to initialize the string with exactly the same name?
The string is later used for recognisability.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
