Visual C++ .NET/Class/pin ptr
Using pin_ptr
#include "stdafx.h"
using namespace System;
value class MyClass{
int i, j;
public:
void PrintStartingAddress()
{
interior_ptr<MyClass> ptr_to_this = this;
pin_ptr<MyClass> pinned_this = ptr_to_this;
Console::WriteLine("Starting address of object is 0x{0:x}",reinterpret_cast<int>(pinned_this));
}
};
int main()
{
MyClass v;
v.PrintStartingAddress();
}