Topic: " this" 是什么意思 看了半天还是不懂 请指教! |
Print this page |
1." this" 是什么意思 看了半天还是不懂 请指教! | Copy to clipboard |
Posted by: yujian Posted on: 2006-01-13 10:28 " this" 是什么意思 看了半天还是不懂 请指教! |
2.Re:" this" 是什么意思 看了半天还是不懂 请指教! [Re: yujian] | Copy to clipboard |
Posted by: blueoxygen Posted on: 2006-01-13 11:00 this instance |
3.Re:" this" 是什么意思 看了半天还是不懂 请指教! [Re: yujian] | Copy to clipboard |
Posted by: tzutolin Posted on: 2006-01-13 11:53 this 就是指自己本身, 好比說有個類叫做熊貓, this 就是指熊貓自己. |
4.Re:" this" 是什么意思 看了半天还是不懂 请指教! [Re: yujian] | Copy to clipboard |
Posted by: no Posted on: 2006-01-13 14:15 多看看例子就明白了! |
5.Re:" this" 是什么意思 看了半天还是不懂 请指教! [Re: yujian] | Copy to clipboard |
Posted by: dzm521 Posted on: 2006-01-13 14:23 当我们调用方法的时候,系统除了要传递形参外,还要传递方法所属对象的地址,正如: 对象名.方法名(参数...);如果用THIS关键字,就说明你想调用的是使用这个类所创建的那个对象(由于那个对象现在并没有创建,而是在调用这个类时才创建,所以JAVA语言提供了这种方式),也可以不写THIS,系统会默认加this关键字 THIS还有一个用处就是:如果方法中的形参名和类中的变量同名的话,使用THIS就说明是类中的变量而不是行参,如: ... int b; ... a(int b) { this.b = b;//this.b是类中定义的b; //b是传递进来的参数b } |
6.Re:" this" 是什么意思 看了半天还是不懂 请指教! [Re: yujian] | Copy to clipboard |
Posted by: 紫枫 Posted on: 2006-01-13 17:56 指向自己~~ 对吗? |
7.Re:" this" 是什么意思 看了半天还是不懂 请指教! [Re: yujian] | Copy to clipboard |
Posted by: allenchen Posted on: 2006-01-13 23:35 面向对象的语言,this是这样用C实现的,看看就明白了。 声明: int method(Object* this, ...); 调用: Object obj; method(obj, ...); 用C++这样写 class Object { public: int method(...) { }; }; 用JAVA跟C++道理差不多。可见this就是实例本身。 |
8.Re:" this" 是什么意思 看了半天还是不懂 请指教! [Re: yujian] | Copy to clipboard |
Posted by: 轻薄的假象 Posted on: 2006-01-14 11:18 虽然JAVA中没有指针的概念,但THIS就相当于指针,指的是自己(本类) 技巧方面,可以在成员函数中为避免与参数变量名重名时而调用成员变量,另一个用途就是象其他(或本类)传递或ADD类的对象时,避免new方法而使用THIS |
9.Re:" this" 是什么意思 看了半天还是不懂 请指教! [Re: yujian] | Copy to clipboard |
Posted by: kof821117 Posted on: 2006-01-23 01:33 this 就是c语言中指针的意思,如果你学过c这样会好懂 |
10.Re:" this" 是什么意思 看了半天还是不懂 请指教! [Re: kof821117] | Copy to clipboard |
Posted by: ranchgirl Posted on: 2006-01-23 05:51 kof821117 wrote: Wrong!!! Please don't teach others, if you don't understand at all! Thanks! |
11.Re:" this" 是什么意思 看了半天还是不懂 请指教! [Re: yujian] | Copy to clipboard |
Posted by: blueoxygen Posted on: 2006-01-23 09:16 this到底指向哪里还不能确定的吧。 我记得一个Class TestA 当new出来两个instance testa,testb的时候 他们的实例变量是各自维护的 但是方法和静态变量等在内存中是公用一块内存区域的。 也不知道记错没,查查去~~~ |
12.Re:" this" 是什么意思 看了半天还是不懂 请指教! [Re: 紫枫] | Copy to clipboard |
Posted by: ranchgirl Posted on: 2006-01-23 09:29 紫枫 wrote: 对!!!! Nothing else. |
13.Re:" this" 是什么意思 看了半天还是不懂 请指教! [Re: yujian] | Copy to clipboard |
Posted by: hotfire00 Posted on: 2006-01-25 11:57 java中应该是没有指针的!! this就应该是本身 |
14.Re:" this" 是什么意思 看了半天还是不懂 请指教! [Re: yujian] | Copy to clipboard |
Posted by: 逆风飞扬呀 Posted on: 2006-02-22 16:27 说是没有指针,但是和指针有什么区别呢? 请高手指教。 个人认为只是名字没有指针而已,但是Java中使用的就是经过限制了的指针。 |
15.Re:" this" 是什么意思 看了半天还是不懂 请指教! [Re: yujian] | Copy to clipboard |
Posted by: 史坑蛆 Posted on: 2006-02-22 23:45 当你用两个类编写和运行就知道了 |
16.Re:" this" 是什么意思 看了半天还是不懂 请指教! [Re: yujian] | Copy to clipboard |
Posted by: MagicStar Posted on: 2006-03-08 09:26 this和Delphi中的Self应该是相同的概念,有一点面向对象的基础 理解起来应该会容易一些,这一点C++、Java、Delphi方面有 相通性。 |
Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1 客服电话 18559299278 客服信箱 714923@qq.com 客服QQ 714923 |