现实生活中的指针示例 [英] real life example of pointers

查看:94
本文介绍了现实生活中的指针示例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,





任何人都可以向我解释指针实际用于(现实生活中的应用程序)的地方,而不是交换两个变量。任何一个例子??

i知道指针是存储其他变量的内存地址的特殊变量,但是有什么用??

我们可以知道任何内存地址通过在printf或cout中使用&(变量)变量...



谢谢

Hello everyone,


Can anyone explain to me where pointers are actually used in (real life applications) other than swapping two variables. any example ??
i know that pointers are special variables that stores memory address of other variable, but whats the use ?...
we can know the memory address of any variable by using &(variable) in printf or in cout...

Thanks

推荐答案

请看看我对这个问题的评论。



尽管这对初学者来说是一个非常有用的问题,但这不是一个好问题,也不是一个好的学习方法。好像你对指针的重要性有疑问,并希望有人说服你。



你看,没有简短的现实生活的例子不会给你带来好处图片。你甚至不应该考虑在C或C ++编程层面上有任何指针的替代品(当然,你总是可以隐藏更高级抽象背后的指针,它可能非常富有成效,但要理解它是如何工作的,你会需要......非常好的指针经验)。同时,如果你只是开始学习编程(不一定是C ++或C),你需要一直处理指针,所以从第一堂课开始,你的问题就会自动消失。



-SA
Please see my comment to the question.

Even though this is quite a valid concern for a beginner, this is not a good question and not a good approach to learning. As if you had a doubt in importance of pointers and wanted someone to convince you.

You see, no short "real life" example won't give you a good picture. You should not even think about having any alternatives to pointers at the level of C or C++ programming (of course, you can always hide pointers behind higher-level abstraction, and it can be quite fruitful, but to understand how it works, you would need… very good experience with pointers). At the same time, if you simply start learning programming (not necessarily C++ or C), you will need to deal with pointers all the way, so your question will disappear by itself, starting from the very first lessons.

—SA


快速搜索谷歌会帮助你解答这个问题,但这是一个很好的例子:< br $> b $ b

http://stackoverflow.com/questions/162941 / why-use-pointers [ ^ ]



如果你想要真实世界的例子,请在SourceForge上的一些开源项目中查看实际代码。
A quick search on google would help you answer this, but here is a good example:

http://stackoverflow.com/questions/162941/why-use-pointers[^]

If you want "real world" examples, start looking at real code in some open source project on SourceForge.


这篇关于现实生活中的指针示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆