What is the real difference between Pointers and References?

后端 未结 22 2848
南方客
南方客 2020-12-01 04:33

AKA - What\'s this obsession with pointers?

Having only really used modern, object oriented languages like ActionScript, Java and C#, I don\'t really understand the

22条回答
  •  甜味超标
    2020-12-01 05:19

    Historically, what made programming possible was the realization that memory locations could hold computer instructions, not just data.

    Pointers arose from the realization that memory locations could also hold the address of other memory locations, thus giving us indirection. Without pointers (at a low level) most complicated data structures would be impossible. No linked-lists, binary-trees or hash-tables. No pass by reference, only by value. Since pointers can point to code, without them we would also have no virtual functions or function look up tables.

提交回复
热议问题