Registriert: Mi Dez 15, 2004 20:36 Beiträge: 454 Wohnort: Wien, Österreich
In delphi32 there is no operator overloading. You simply must write your own function witch does that. And if you declare and implement the function in the same unit where you declared your classes, this function could serve as an "friend" function in C++ manner.
Example:
Code:
type
TVector =class
private
fX, fY, Fz :Single;
public
property X:Singleread fX write fX;
property Y:Singleread fY write fY;
property Z:Singleread fZ write fZ;
end;
procedure VectorAdd( v1, v2, result :TVector );
implementation
procedure VectorAdd( v1, v2, result :TVector );
begin
result.fX:= v1.fX+ v2.fX;// you cann access the private members since you are in the same unit !!!
result.fY:= v1.fY+ v2.fY;// this is like a friend function in c++
result.fZ:= v1.fZ+ v2.fZ;
end;
And Quake3 is written in C, so there are no classes there, and of course no operator overloading.
_________________ "Meine Mutter sagt : 'Dumm ist der, der Dummes tut'." - Forrest Gump
Registriert: Di Mai 18, 2004 16:45 Beiträge: 2621 Wohnort: Berlin
Programmiersprache: Go, C/C++
You can use FreePascal, it support stuff like this.
You find it under this link http://www.freepascal.org
irony_mode:=true;
But it is a free compiler and you don't pay money, its cross and build much faster code like delphi and gcc.
It have no ide and for OpenGL you need a visuell development envoirement because only on this way you can use the not existing vcl on your OGL Projekt.
irony_mode:=false;
_________________ "Wer die Freiheit aufgibt um Sicherheit zu gewinnen, der wird am Ende beides verlieren" Benjamin Franklin
Registriert: Sa Nov 12, 2005 04:05 Beiträge: 7 Wohnort: eu
sniper hat geschrieben:
In delphi32 there is no operator overloading. You simply must write your own function witch does that. And if you declare and implement the function in the same unit where you declared your classes, this function could serve as an "friend" function in C++ manner.
Example:
Code:
type
............
And Quake3 is written in C, so there are no classes there, and of course no operator overloading.
and C#? Sorry C are more performant language, as english compare with german's + ae, oe, ue etc.
Registriert: Di Mai 18, 2004 16:45 Beiträge: 2621 Wohnort: Berlin
Programmiersprache: Go, C/C++
The fastest language is that which use a compiler who generate the fastest asm routine(not the shortest because every asm call need different cycles for a call).
Thats mean if you have a compiler which check every assignment for valid values and have no checker for stupid codeblocks like "if 1=1 then" or use other not needed code it will be slow down the binary. C must not the fastest and Java not the slowest because its dependent on compiler.
_________________ "Wer die Freiheit aufgibt um Sicherheit zu gewinnen, der wird am Ende beides verlieren" Benjamin Franklin
Registriert: Sa Nov 13, 2004 11:00 Beiträge: 229 Wohnort: Steinhude
not to forget the degree of optimizations a specific compiler depends mostly on the kind of routines it's given, because even the compiler generating the fastest code in general has some points, where it doesn't optimize to the perfect implementation (probably most of the time) and other compilers which are optimized better for this job will generate a better solution for the given task
result.fY:= v1.fY+ v2.fY;// this is like a friend function in c++
That´s wrong. A friend function means, that an other class or function has access to protected and private elements of a class.
In this case it' s an instance of the same class type, so I can use all private things, because "i am in the same class type". That`s the normal way of object orientaded programming
Mitglieder in diesem Forum: 0 Mitglieder und 26 Gäste
Du darfst keine neuen Themen in diesem Forum erstellen. Du darfst keine Antworten zu Themen in diesem Forum erstellen. Du darfst deine Beiträge in diesem Forum nicht ändern. Du darfst deine Beiträge in diesem Forum nicht löschen. Du darfst keine Dateianhänge in diesem Forum erstellen.