- vector {
- float x,y,z
- }
DGL https://delphigl.com/forum/ |
|
C++ Class Operator in Pascal https://delphigl.com/forum/viewtopic.php?f=19&t=4798 |
Seite 1 von 2 |
Autor: | Gast [ Mi Nov 02, 2005 12:24 ] |
Betreff des Beitrags: | C++ Class Operator in Pascal |
Hello guys, Since you are working on Quake 3 to Delphi conversion, maybe you have some ideas on the following problem: In C++ there is a function to assign operator to a class,i thougt it was called Operator Overloading. Let's say we got a vector class: Code:
In C++ it is possible to make a function which handles, for example, the substration of the 2 classes. So when you use Code:
it is using your own made function. I know that with Delphi 2005 and .NET it is possible, but how do you guys solve it without .NET? Thanks in advance -Ice3 |
Autor: | sniper [ Mi Nov 02, 2005 12:55 ] |
Betreff des Beitrags: | |
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:
And Quake3 is written in C, so there are no classes there, and of course no operator overloading. |
Autor: | LarsMiddendorf [ Mi Nov 02, 2005 13:33 ] |
Betreff des Beitrags: | |
Delphi2006 supports operator overloading also in Win32. The syntax will be the same as for the .Net version. |
Autor: | Gast [ Fr Nov 04, 2005 10:44 ] |
Betreff des Beitrags: | |
Thanks, you both! I will use sniper_w code for now, but when Delphi 2006 comes out, i'll look into that! Thanks again -Ice3 |
Autor: | TAK2004 [ Do Dez 01, 2005 09:29 ] |
Betreff des Beitrags: | |
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; |
Autor: | delphiXYZ [ Do Dez 08, 2005 13:15 ] |
Betreff des Beitrags: | |
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:
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. MfG berlinea screen TFT |
Autor: | sniper [ Do Dez 08, 2005 18:14 ] |
Betreff des Beitrags: | |
Zitat: and C#? Sorry C are more performant language, as english compare with german's + ae, oe, ue etc. ![]() |
Autor: | LarsMiddendorf [ Do Dez 08, 2005 19:30 ] |
Betreff des Beitrags: | |
He probably means that a pure language without any extensions is the fastest, but that's obviously wrong. |
Autor: | TAK2004 [ Do Dez 08, 2005 20:46 ] |
Betreff des Beitrags: | |
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. |
Autor: | Grizzly [ Fr Dez 09, 2005 23:01 ] |
Betreff des Beitrags: | |
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 |
Autor: | Flash [ So Dez 11, 2005 03:08 ] |
Betreff des Beitrags: | |
Java code is defenitly slower then normal c/pascal code because it has to be "compiled" at the first run. But that's not the point... ![]() |
Autor: | delphiXYZ [ Do Dez 15, 2005 00:14 ] |
Betreff des Beitrags: | MagicGeometry |
Code:
|
Autor: | delphiXYZ [ Do Dez 15, 2005 00:16 ] |
Betreff des Beitrags: | |
Flash hat geschrieben: Java code is defenitly slower then normal c/pascal code because it has to be "compiled" at the first run. But that's not the point... and Quick Basic is "implementator", other ? ![]() ![]() |
Autor: | delphiXYZ [ Do Dez 15, 2005 00:22 ] |
Betreff des Beitrags: | |
sniper hat geschrieben: .......
Code:
And Quake3 is written in C, so there are no classes there, and of course no operator overloading. |
Autor: | Pellaeon [ Fr Dez 23, 2005 09:06 ] |
Betreff des Beitrags: | |
sniper hat geschrieben: Code:
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 ![]() |
Seite 1 von 2 | Alle Zeiten sind UTC + 1 Stunde |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |