There is the following code:
#define VAR_NAME(Var) (#Var) #include <cstdlib> #include <string> struct cfg_pair{ std::string marker, value; cfg_pair(const char * name): marker("\r\n"+std::string(name)+"=") {} bool Init(std::string &buffer){ if( marker.empty() ) return false; int beg = buffer.find(marker); if( beg < 0 ) return false; beg += marker.size(); int end = buffer.find("\r\n",beg); if( end < 0 ) end = buffer.size(); value = buffer.substr(beg,end-beg); return true; } }; int main(int argc, char** argv) { cfg_pair test(VAR_NAME(test)); printf("%s\n",test.marker.c_str()); return 0; } Is it possible to make the marker field initialized with the name of the created cfg_pair object without passing any arguments to the constructor? That is, just "from the inside" somehow take the name of the object (in this case, test )?