So basically, everything between C/C++ and pascal are nearly identical, [...] So technically, anything possible with C/C++ is possible with Pascal?
No.
They are *mostly* the same, but there are things you can do with C that you cannot with Pascal, and vice versa.
Of course, this relates to some pretty advanced stuff, you should be quite experienced in programming to get grip of it.
C has multiple inheritance and tons of other techniques (perverted IMO) you can't easily replicate in Pascal. Also, C has generics and Pascal doesn't (yet). I cannot be of much help here because I'm not familiar with C/C++ myself.
Pascal has metaclasses - a unique feature you won't find in C++. So, for example, my persistency system would be impossible to create with C++.
Metaclasses are quite powerful feature, allowing to decide created object's type at runtime in a very easy and elegant manner. Metaclasses also allow you to write, for example, methods for class to clone itself that will work correctly with all its descendants:
Code:
type
TFrog = class
constructor RibbitCreate; virtual;
function OneMore: TFrog;
end;
CFrog = class of TFrog;
TToad = class(TFrog);
...
function TFrog.OneMore: TFrog;
begin
Result:=CFrog(Self.ClassType).RibbitCreate;
//Typecast to CFrog is required here because ClassType() returns TClass,
// but TClass doesn't have the RibbitCreate constructor
end;
If you call TToad's OneMore you will get TToad, not TFrog, despite the fact that the method is inherited from TFrog unchanged.
AFAIK, you can't do such things in C.
Bookmarks