nikitablack
nikitablack

Reputation: 4663

Find address of a class member when debugging in VS

The story so far - I have some class. This class have some members of different types. In some function I set a breakpoint and now I want to see the address of members. But I can't - Locals window shows only values. Here's a picture:

enter image description here

As you can see - for this pointer I have memory address displayed (0x000000000bca0a40), but for anything inside it (InstanceBodyIndex for example) - no.

How can I obtain this addresses?

Upvotes: 2

Views: 930

Answers (2)

prehistoricpenguin
prehistoricpenguin

Reputation: 6326

Add one additional answer since moldbnilo's answer doesn't work perfectly for nest classes. (Tested with VS2015)

  • Add watch for the outmost object
  • Click to expand the object's nest member
  • Right-click on the member's name, choose Add watch
  • We will get one more watch name on the watch window(It's a generated expression and may be complex), name it as EXPR
  • copy the EXPR, and wrapper it as &(EXPR), then we get the address of nest member

enter image description here

Upvotes: 0

molbdnilo
molbdnilo

Reputation: 66371

Open the "Watch" window.

Add the variable you're interested in with the address-of operator in front, e.g. "&InstanceBodyIndex".

Upvotes: 4

Related Questions