|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Passing Class Parameters??
I have this line of code that I am using in C++
Code:
CreateMachineID(TEsMachineInfoSet() << midUser); As I understand I am passing class parameters to CreateMachineID method. I want to know how to use this line of code in Delphi. Simply replacing "<<" with "shl" does not work. As usual, I appreciate any help anyone can give me. Thanks. |
|
#2
|
||||
|
||||
|
the "<<" in C++ is the Shift Left operator. its Delphi equivalent is the function Shl...
as long as "TEsMachineInfoSet" and "midUser" are both numeric, there's no reason why it won't work. so, what you mean by "does not work"? you get error on compile? during run time? nothing happens? the computer freeze? please give more details. |
|
#3
|
||||
|
||||
|
Quote:
Close, but not quite correct in the context of C++ Builder. You're quite correct that << is normally the C++ bit shift left operator, but don't forget that operators can be overloaded (for instance, cout << "foo" prints a string, since << is overloaded for the cout object). When there is a set of flags to be passed to a function, C++ Builder tends to overload << as a setflag function. Thus TEsMachineInfoSet() << midUser is passing a TEsMachineInfoSet() set object and setting the midUser member for this set object before passing it to the function. The Delphi equivalent of a set is to place it within [ and ]. Code:
CreateMachineID([midUser]); If you had two flags to set, the C++ Builder version would look like this: Code:
SomeFunc(TSomeSetObject() << flag1 << flag2); and the Delphi equivalent would look like this: Code:
SomeFunc([flag1, flag2]);
__________________
Up the Irons What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home. "Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest Down with Sharon Osbourne Puzzle of the Month solved by Keath and KevinADC, superior perl programmers of the month |
|
#4
|
||||
|
||||
|
cool, didn't know that it exists in C++ - steve also said he tried using Shl function
thus I assumed he was trying to indeed use the shift left operator. well, it's always good to learn some new stuff! ![]() |
|
#5
|
|||
|
|||
|
Thanks a lot Scorpions! Once again you've been most helpful in solving my problem. (I appreciate your input too, Shadow Wizard). I only wish I knew enough to help with some the other questions around here.
Thanks |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Delphi Programming > Passing Class Parameters?? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|