Originally Posted by
chronozphere
I'm especially interested in how inheritance is done with procedural programming.
An example:
Code:
TYPE
TClassA = RECORD
PropA: INTEGER;
END;
TClassB = RECORD
Parent: TClassA;
PropB: INTEGER;
END;
Assuming INTEGER as 32 bit, both records have the "same" first 32 bit, so you can do something like this:
Code:
VAR
TheObject: TClassB;
OtherInstance: ^TClassA;
BEGIN
OtherInstance := POINTER (@TheObject);
OtherInstance^.PropA := 1;
WriteLn (TheObject.Parent.PropA);
END;
Add procedures and funcitions to the equation and here you have the beggining.
Originally Posted by
chronozphere
(...) For example, if you heavily rely on complex things like polymorphism, generics or operator overloading, it will be very hard to understand what's going on.
That's why I never use generics nor operator overloading. When I programmed C++ I had lots of problems with that. Sepcially with operator overloading, because a lot of times the compiler selected the wrong one doing weird conversions and returning bad data. The worst is that data is "valid" so it's hard to find where the problem is.
BTW, I think most people don't use it correctly. It seems as they're using it because it's cool or because everybody uses it, but I'm not sure if they're really think about if it's really useful or helps to the development.
Bookmarks