简体   繁体   English

C ++程序中的指针大小

[英]Pointer Size in a C++ program

我知道指针大小取决于系统的体系结构,但是当考虑虚拟内存并且说它大于物理内存时,那么变量指针大小如何受到体系结构的限制?

A pointer must be able to hold the address of any location in memory. 指针必须能够保存内存中任何位置的地址。 As a result, a 32 bit system (usually) needs a 32 bit pointer! 因此,32位系统(通常)需要32位指针!

Note the "usually" here, as member function pointers can be completely different in size and there are many other exceptions to this rule of thumb. 注意这里的“通常”,因为成员函数指针的大小可以完全不同,并且这个经验法则还有许多其他例外。 If in doubt, or it matters a lot, write a quick program to check on the architecture you're targeting. 如果有疑问,或者它很重要,请编写一个快速程序来检查您所针对的架构。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM