naming conventions - C++: how to get the path of a variable? -
i know whether it's possible (at runtime) unique name each variable in c++ program. example, if in main declare
myclass a;
and in myclass declare
int i;
i'd magic forumla returns "main/a/i".
does exists?
thank you!
the purpose of keeping track of variable assignments. wrote class use wrapper standard data type. constructor class accepts string, identify each variable.
the problem occurrs when have variable declared in class, , multiple instantiations of class. i.e.
class myclass { ... myint data ("variable_name"); // myint wrapper int ... }; ... int main () { ... myclass a; myclass b; ... }
statically initializing name of data make impossible dintinguish between a.data , b.data. suggested, use maybe use memory address id, how possible map address human readable path?
unless you're doing additional work (when declaring data structures), in general not possible in c++. there's no such data stored anywhere in program.
and indeed, 1 of commenters mentioned, in cases, in platform-specific way if have debug data (like pdb in windows), may able debuggers do.
Comments
Post a Comment