NOTE: I'm not trying to solve a programming problem; I'm trying to learn.
Given this c++ code:
#include <iostream>
class class1
{
public:
int attr1 = 12;
class1()
{
} // breakpoint
};
int main()
{
class1 c1;
}
Using VS2019; breakpoint set per above. In Immediate Window:
this
0x000000877f54fcf4 {attr1=0x0000000c }
attr1: 0x0000000c
attr1
0x0000000c
class1::attr1
0x0000000c
&(class1::attr1) (am able to use "class1" here, I assume, because it's clear I'm not referring to a typename)
0x000000877f54fcf4 {0x0000000c}
class1 (returns blank line?)
&class1 (treats class1 as type)
type name is not allowed
Also, in Memory window, entering "class1" in Address
field shows:
Unable to evaluate the expression.
At the breakpoint, my questions:
- How can I get the address of class1 in the immediate window by using the identifier "class1"? (yes, I know it's the same address as "this")
- Same question re: Memory window
- Why does "class1" in Immediate Window return blank?
I am guessing that you wish to access the RTTI of the class. Chances are, different compilers may implement it slightly differently to one another.
That said, there is an operator called
typeid
: https://en.cppreference.com/w/cpp/language/typeidTake a look at this blog for an example of using it with the Visual-C compiler: https://blog.quarkslab.com/visual-c-rtti-inspection.html
which features this example:
which outputs:
If you're interested in accessing the debug information in the PDB file (MSVC) then take a look at the answers to this question: Do debugging information reveal code in C++ / MSVC?