how many bytes takes a pointer to a function and a pointer to a reference? | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
+ 2

how many bytes takes a pointer to a function and a pointer to a reference?

25th Mar 2018, 6:25 PM
Vitos
3 Réponses
+ 5
There is no fixed answer; it depends entirely on the architecture, the compiler implementation, and even the type of the pointer itself. Pointers to different types are not guaranteed to have the same size and/or representation. For example, assume a word-addressed architecture, where the smallest addressable unit of storage is 16 bits wide (or wider). Each word can hold multiple char values; all other types take up a full word or more. On such an architecture, a char * and void * would need some extra bits to offset into the word compared to other pointer types. Note also that a pointer type may be wider than the number of bits actually required to store an address. The original Macintosh ran on a Motorola 68000 CPU, which had a 32-bit word size, but only 24 bits on the address bus. Pointer types were 32 bits wide, leaving the upper 8 bits unused. Enterprising MacOS programmers took advantage of that to store some data to the uppermost byte of a pointer type, making the most of that precious 128 KB of RAM. Of course, Motorola eventually released a CPU with 32 address lines (the 68020), meaning all that code had to be rewritten. On modern, commodity desktop and server hardware (read: x86), it's reasonably safe to assume that all pointer types are the same size as the native word size (32- or 64-bit), and that all pointer types have the same size and representation. Just be aware that this doesn't have to be true.
25th Mar 2018, 6:43 PM
Baraa AB
Baraa AB - avatar
+ 3
Welcome bro 💚 good luck ..
25th Mar 2018, 7:20 PM
Baraa AB
Baraa AB - avatar
+ 2
thank you very much
25th Mar 2018, 6:53 PM
Vitos