| View previous topic :: View next topic |
| Author |
Message |
slippppppppp Grandmaster Cheater
Reputation: 0
Joined: 08 Aug 2006 Posts: 929
|
Posted: Wed Nov 21, 2007 11:12 pm Post subject: [Delphi] - [CPP] conversion |
|
|
In c ++,
the code:
| Code: | static const blahhh;
|
Blahh is defined as a static const.
But, how would i convert that to delphi?
I already know, you reverse it as in:
| Code: | | Blahh : static const |
but, static const isnt a type of var in delphi.
|
|
| Back to top |
|
 |
appalsap Moderator
Reputation: 0
Joined: 27 Apr 2006 Posts: 6753 Location: Pakistan
|
Posted: Wed Nov 21, 2007 11:54 pm Post subject: |
|
|
when I put
| Code: |
static const blahhh;
|
in a source file, the compiler warns me saying
| Code: |
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
|
That line doesn't make sense either, if it's a constant it should have some sort of value since you can't modify it later. If it does have a value and you've just omitted that for the post, when converted to delphi it should go under const, not var.
tl;dr integer
_________________
|
|
| Back to top |
|
 |
slippppppppp Grandmaster Cheater
Reputation: 0
Joined: 08 Aug 2006 Posts: 929
|
Posted: Thu Nov 22, 2007 1:09 am Post subject: |
|
|
| It does have a value, it's value is loadlibrary, thats about it.
|
|
| Back to top |
|
 |
Uzeil Moderator
Reputation: 6
Joined: 21 Oct 2006 Posts: 2411
|
Posted: Thu Nov 22, 2007 3:34 am Post subject: |
|
|
No, static const blahhh; doesn't specify as to what blahhh is to contain, which can't happen with a constant, as you must initiate a value upon their declaration(Because they can't be modified later in code.).
Should be C++, I'm not actually sure if you need to declare variable types in C++ for constants or if the preprocessor/compiler gets it for you.
| Code: | | final int blahhh = 10; | Should be Java... just giving an example of another keyword here.
Delphi.
_________________
|
|
| Back to top |
|
 |
TheSorc3r3r I post too much
Reputation: 0
Joined: 06 Sep 2006 Posts: 2404
|
Posted: Thu Nov 22, 2007 9:13 am Post subject: |
|
|
Uzeil, you do need to declare the type in C++:
| Code: | | static const int blehh= 0; |
in delphi, you can make a whole list of constants if you want, using the keyword only once (this is from memory, I haven't used delphi in a while)..
| Code: | const
blehh = 10;
blehh2 = 20; |
_________________
Don't laugh, I'm still learning photoshop! |
|
| Back to top |
|
 |
HolyBlah Master Cheater
Reputation: 2
Joined: 24 Aug 2007 Posts: 446
|
Posted: Thu Nov 22, 2007 10:20 am Post subject: |
|
|
here it is:
| Code: | Const
[name]:[Type]=[value]
Ex:
Const
IAmAnInteger:integer=123;
IAmAString:String='Blah FTW~!';
|
|
|
| Back to top |
|
 |
rapion124 Grandmaster Cheater Supreme
Reputation: 0
Joined: 25 Mar 2007 Posts: 1095
|
Posted: Thu Nov 22, 2007 11:09 am Post subject: |
|
|
In delphi, you do not need to specify the type of data for a constant like you do for C++.
This is legal in Delphi:
This is also legal in C++:
| Code: | | static const blahh = 10 |
Because 10 to the compiler is an integer. Therefore, you can omit the type.
|
|
| Back to top |
|
 |
slippppppppp Grandmaster Cheater
Reputation: 0
Joined: 08 Aug 2006 Posts: 929
|
Posted: Thu Nov 22, 2007 1:40 pm Post subject: |
|
|
You guys dont get it, what im trying to convert is
C++
| Code: | | static const blahh = getmodulehandle(loadlibrary , ect. |
And, convert it to delphi
|
|
| Back to top |
|
 |
HolyBlah Master Cheater
Reputation: 2
Joined: 24 Aug 2007 Posts: 446
|
Posted: Thu Nov 22, 2007 3:21 pm Post subject: |
|
|
| slippppppppp wrote: | You guys dont get it, what im trying to convert is
C++
| Code: | | static const blahh = getmodulehandle(loadlibrary , ect. |
And, convert it to delphi |
const
blahh :Thandle=getmodulehandle(loadlibrary , ect.
|
|
| Back to top |
|
 |
killersamurai Expert Cheater
Reputation: 0
Joined: 10 Sep 2007 Posts: 197 Location: Colorado
|
Posted: Thu Nov 22, 2007 4:12 pm Post subject: |
|
|
You will not be able to use LoadLibrary with GetModuleHandle.
LoadLibrary returns HMODULE and GetModuleHandle takes in a LPCTSTR ( pointer to a constant string). Static doesn't exist in delphi as far as I know. Also, I always get an error when trying to assign a variable that is constant with a function that returns something in delphi. What I would do is
| Code: |
procedure TForm1.Button1Click(Sender: TObject);
var
something : HModule;
begin
something := GetModuleHandle('user32.dll');
...........
end;
end.
|
|
|
| Back to top |
|
 |
|