Advertisement
2_2002-2004 Coding Standards #127995

Code Example - reinterpret_cast

shows how to use reinterpret_cast :)

AI

AIサマリー: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

ソースコード
original-source
#include<iostream>
using namespace std;
class M {
public:
	int x;
	int y;
	int z;
	void print()
	{
		cout << "x: " << x << " y: " << y << " z: " << z << endl;
	}
};
int main()
{
	M m;
	int *p = reinterpret_cast<int*>(&m);
	*p = 0;
	p++;
	*p = 5;
	p++;
	*p = 7;
	m.print();
	system("pause");
}
オリジナルのコメント (3)
Wayback Machineから復元