Show typically uses and does what what std::cout provides, and little else.ĭump does what show does, but also might provide an alternate view of the data, either hex or binary translations of the values, or perhaps tables. and most of my objects also have both show() and dump(), and there can be multiple show/dump functions or methods, each with different signatures, and default values. Typically, I use one of two (what I call) disposable debug methods. if I do a particular something 3 (or more) times (like generate a std::cout statement with the same or similar variables in it) then I might write a function (rather than copy the line) for that repeated effort. not required) function is appropriate for doing something you wish to repeat. My view is that creating a 'convenience' (i.e. I use std::cout and std::cerr (as defined) for lots of debugging, but not in the 'how can I save the most typing' frame of mind. Or do C++ people just always define their own simple print function or something? GDB can 'dump' automatic variables with no _effort_ at all, as automatic var's for the current stack frame are always kept up-to-date in the "Locals" window. You can tryout the template methods provided by other answer's.īut you should try GDB (or some debugger available on your system). But I do not consider std::cout a challenging amount to type. I would have to say No, not in the language. Is there a more convenient (less key-strokes) way to quickly dump a
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |