带有C-查询的指针 [英] Pointers with C- a query

查看:60
本文介绍了带有C-查询的指针的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的,

我有以下疑问,而java能够随身携带

指针为什么C语言无法被修改以删除指针?Hows java

能用指针做到这一点吗?

我很抱歉对那些建议我发布给java人的人抱歉

因为我已经完成它。

Jus想知道可以与

C.一起使用的指针的替代品。而指针提供灵活性大多数错误都是关于

指针。如果我们能够放弃

指针或进行某种修改(我不知道怎么做,但它可以

)会不会很好考虑进行研究)这样我们的s / ws更加纯净,而不是
错误?


我很抱歉我的过早查询,但它会是很有帮助,我会是

感谢所有让我理解这一点的人。

问候,

s.subbarayan

Dear all,
I had this following doubt,while java is able to carryon with out
pointers why C language cant be modified to remove pointer?Hows java
able to do this with out pointers?
I jus plead sorry to those who advice me to post it to java people
because I have already done it.
Jus want to know alternatives to pointers which can be used with
C.While pointers provide flexibility most bugs are with respect to
pointers.So will it not be good if we are able to either forgo the
pointers or do some sort of modification(I am not aware how,but it can
be considered for research) so that our s/w s are more pure with out
bugs?

I am sorry for my amature query,but it will be helpful and I will be
thankful to all who makes me understand this.
Regards,
s.subbarayan

推荐答案

s.subba rayan写道:
s.subbarayan wrote:
亲爱的,
我有以下疑问,而java能够随身携带
指针为什么C语言无法修改删除指针?
Dear all,
I had this following doubt,while java is able to carryon with out
pointers why C language cant be modified to remove pointer?




为什么世界上有人想要?你的问题类似于

问为什么不是人们只是切断他们的左臂?



Why in the world would anyone want to? Your question is similar to
asking "why don''t people just cut off their left arms?".


s.subbarayan写道:
s.subbarayan wrote:
亲爱的,
我有以下疑问,而java能够随身携带
指针为什么C语言不能修改删除指针?如果你能用指针做到这一点吗?
我很抱歉向那些建议我发布给java人的人抱歉
因为我已经做过了。
Jus想要知道可以与
一起使用的指针的替代品C.虽然指针提供了大多数错误指针的灵活性。所以如果我们能够放弃
会不会很好指针或做某种修改(我不知道如何,但它可以考虑进行研究),以便我们的s / ws更纯粹,没有错误?
我很抱歉我的过早查询,但它会有所帮助,我将感谢所有wh o让我理解这一点。
Dear all,
I had this following doubt,while java is able to carryon with out
pointers why C language cant be modified to remove pointer?Hows java
able to do this with out pointers?
I jus plead sorry to those who advice me to post it to java people
because I have already done it.
Jus want to know alternatives to pointers which can be used with
C.While pointers provide flexibility most bugs are with respect to
pointers.So will it not be good if we are able to either forgo the
pointers or do some sort of modification(I am not aware how,but it can
be considered for research) so that our s/w s are more pure with out
bugs?

I am sorry for my amature query,but it will be helpful and I will be
thankful to all who makes me understand this.




当你在Java程序中传递对象时,你实际上是在传递''指针'
'(参考)。在Java中你不会写* / b $ *和&正如你在C中所做的那样,因为使用''指针''

已内置于该语言中。


我认为不可能写结构良好的C

程序,不使用指针。指针有几个应用程序

,没有这些应用程序很难实现:


a。将大量数据传递给函数(避免制作

本地副本。

b。将数据传递给要在内部修改的函数。

c各种''面向对象''编程技术使用函数

指针。

d。创建可变大小的数据结构,如树,列表,...
e。...


也许我们可以说命令式编程语言做得很好

带有内存地址的抽象表示(其中''是'一个

指针)?至少这可能会产生一些有趣的

响应。;-)


基斯别名案例



When you pass around objects in a Java program you''re actually
passing around ''pointers'' (references). In Java you don''t write
the * and & as you would do in C because working with ''pointers''
has been built into the language.

I would argue that it is impossible to write well structured C
programs without using pointers. There are several applications
for pointers, which are hard/stupid to implement without:

a. Passing large chucks of data to functions (avoiding making
local copies.
b. Passing data to a function to be modified inside.
c. Various ''object-oriented'' programming techniques using function
pointers.
d. Creating variable size data-structures like trees, lists, ...
e. ...

Perhaps we could say that imperative programming languages do well
with an abstract representation of a memory address (which ''is'' a
pointer)? Well at least this might result in some interesting
responses. ;-)

Kees alias Case


2004年5月21日06:06:01 -0700, s _ ********** @ rediffmail.com (s.subbarayan)

写道:
On 21 May 2004 06:06:01 -0700, s_**********@rediffmail.com (s.subbarayan)
wrote:
亲爱的,
我有以下疑问,而java能够随身携带
指针为什么C语言不能成为modi fied删除指针?如何用指针来执行此操作?


Java是一种面向对象的语言,并使用引用语言。输入

到对象。原始类型的处理方式或多或少与它们在C中的处理方式相同。因此,Java中存在二分法:对象仅通过引用引用

(为了方便性能和垃圾收集),而

独立(裸)基元直接通过名称引用,如C,

出于性能原因(注意裸体

原语没有垃圾收集。)。 Java中的基元很少需要间接访问;当它们执行时,它们需要将它们包装在一个对象中,然后使用

引用该对象。<另一方面,
C只有一种间接引用数据的机制,

这就是指针。这是镇上唯一的一场比赛;它很好地反映了C''b $ b'与靠近机器的性质,允许使用间接

有无动态分配,甚至垃圾收集,如果你

麻烦为它设置一个自定义框架。指针是最常用的通用方式,并且提供了必要的设备,使得第一个可行的高级(相对而言)系统编程成为可能。

C />
语言。如果你将C修改为删除指针,那么它就不会是C的任何时间。例如,C ++提供了它自己独特的参考风格

类型,适合卸载一些东西,在C中,必须用指针完成
。但即使在C ++中,引用也不是指向

指针的通用替代品。

我恳请那些建议我发布给java人的人抱歉
因为我已经完成了它。
Jus想知道可以与
一起使用的指针的替代品C.而且指针提供灵活性大多数错误都与指针有关。所以它不会很好如果我们能够放弃
指针或进行某种修改(我不知道如何,但它可以考虑进行研究),以便我们的s / ws更纯粹,而不是<虫子?


指针错误的可能性只是你为C给你的低级别控制的价格。它本质上是一种选择(由/某人/,如果不是你个人的b $ b),使用什么语言。如果你需要最大的可能微观管理的话。对于你的应用程序的行为,你最终使用C结果

。如果你愿意付出一些代价(无论是
表现还是学习曲线)你可能会选择使用不同的语言,如Java或C ++或Python,或者

其他的东西。

-leor

我很抱歉我的过早查询,但它会有所帮助,我将感谢所有让我理解这一点的人。
问候,< s.subbarayan
Dear all,
I had this following doubt,while java is able to carryon with out
pointers why C language cant be modified to remove pointer?Hows java
able to do this with out pointers?
Java is an object-oriented language, and uses the "reference" type to refer
to objects. Primitive types are handled more-or-less the same way as they
are in C. Thus there''s a dichotomy in Java: objects gets referred to only
via references (to facilitate performance and garbage collection), while
stand-alone ("naked") primitives are referred to directly by name, as in C,
for performance reasons (note there''s no garbage collection for naked
primitives.). Primitives in Java rarely need to be accessed indirectly;
when they do, you in fact have to wrap them in an object and then use a
reference to that object.

C, on the other hand, has only one mechanism to refer to data indirectly,
and that''s the pointer. It is the only game in town; it reflects well C''s
nature of being "close to the machine", and allows the use of indirection
with or without dynamic allocation, and even with garbage collection if you
take the trouble to set up a custom framework for it. Pointers are the most
general-purpose way to do it, and provided the facilities necessary to make
C the first viable high-level (relatively speaking) systems programming
language. If you modified C to "remove pointers", it wouldn''t be C any
longer. C++, for example, provides its own distinct flavor of reference
type, suitable for off-loading a number of things that, in C, have to be
done with pointers. But references aren''t a universal replacement for
pointers even in C++.
I jus plead sorry to those who advice me to post it to java people
because I have already done it.
Jus want to know alternatives to pointers which can be used with
C.While pointers provide flexibility most bugs are with respect to
pointers.So will it not be good if we are able to either forgo the
pointers or do some sort of modification(I am not aware how,but it can
be considered for research) so that our s/w s are more pure with out
bugs?
The potential for pointer bugs is just the price you pay for the low-level
control C gives you. It is essentially a choice (made by /someone/, if not
you personally) regarding what language to use. If you need the greatest
possible "micro-management" of your application''s behavior, you end up
using C. If you''re willing to pay some price (in terms of either
performance, or learning curve struggles, or code size, or whatever), you
might choose to use a different language such as Java or C++ or Python or
something else.
-leor

I am sorry for my amature query,but it will be helpful and I will be
thankful to all who makes me understand this.
Regards,
s.subbarayan



-

Leor Zolman --- BD软件--- www.bdsoft.com

C / C ++,Java,Perl和Unix的现场培训

C ++用户:下载BD Software的免费STL错误消息解密器:
www.bdsoft.com/tools/stlfilt.html


这篇关于带有C-查询的指针的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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