Advertisement
C_Volume2 Coding Standards #82307

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 恢复