Talk:Consultation (object-oriented programming)

From Wikipedia, the free encyclopedia

"does not preserve late binding of self" - What? --euyyn 12:36, 12 August 2006 (UTC)

When an object sends a message to itself (or invokes a method on itself, that's the same thing), the method is looked up in the object's actual class, not in the class in which the self send occurs. I will illustrate with an example:
public class A
{
   public int foo()
   {
     return this.bar();
   }
   public int bar()
   {
     return 1;
   }
}
public class B
{
   public int bar()
   {
     return 2;
   }
}
A a = new A();
System.out.println(a.foo()); // this will print "1"
A b = new B();
System.out.println(b.foo()); // this will print "2" because of late binding of self
That's just about it. Wouter Lievens 11:30, 13 August 2006 (UTC)
"public class B : public A", right?
Well, so "late binding of self" is "taking the address of virtual member functions through the virtual table" for us, C++ers, aint' it? --euyyn 17:13, 16 August 2006 (UTC)