![]() |
|
#1
|
||||
|
||||
bool and Boolean1.Is there any difference between bool and Boolean in Managed C++ except Boolean being in System namespace.
2. Quote:
__________________
Gravitation is not responsible for people falling in love. -Albert Einstein |
|
#2
|
|||
|
|||
Re: bool and BooleanQuote:
I can't (won't) speak of managed code of any kind or any of the classes of Managed C++. Here are a few things worth knowing about "bool" in Standard C++. 1. "bool" is an integer data type. "bool" is a C++ keyword and can not be used for any other purpose. Note that, unlike other integer data types (int, char, short, long, etc.), there are no separate "signed" and "unsigned" types for "bool". There is only "bool". Note that while sizeof(char) is required by the Standard to be 1, sizeof(bool) is implementation-defined. 2. A variable of type "bool" can have a value of true or false. Operators for operations between "bool" variables (and/or literals) obey the rules that you are probably familiar with. Note that an unitialized "bool" variable may actually have a value that appears to be neither "true" or "false". Note also that results of certain operations on "bool" variables (the "--" operator, for example) are not guaranteed. (In other words, if you expect "--true" to give a value of "false", it may just happen for a particular compiler, but is absolutely and explicitly "not guaranteed" by the Standard. I have actually seen this silliness in code by someone who called himself/herself a Software Engineer. Oh, man! Where is my airsick bag?) 3. If an assignment statement has a "bool" variable on the left hand side, the assigned value is "false" if the right-hand side has a value of zero (or NULL in the case of a pointer), otherwise the assigned value is "true". 4. If a "bool" is used in an arithmetic expression with numerical data types (including an assignment to another data type), a "bool" variable with a value of "false" is converted to zero, and a value of "true" is converted to one. There may be more things to say, but I think these will get you started. If any Managed Code wonks are present, they may be able to answer the question as to what the differences are. I personally don't see the relevance. The question might as well be "What is the difference between C# and Java?" They are different, and someone using one might or might not benefit (or suffer) from knowing the other. I prefer to concentrate on learning one at a time. (But that's just me --- I'm funny that way.) Regards, Dave |
|
#3
|
||||
|
||||
Re: bool and BooleanThanks....Most of the points were familier to me. Let's see if anybody else has to say anything about it.
__________________
Gravitation is not responsible for people falling in love. -Albert Einstein |
|
#4
|
||||
|
||||
Re: bool and BooleanQuote:
"one who studies or works too much; one who is full of oneself (Slang)" Now, that we cleared that up ... alcoholic, In Managed (Extensions for) C++, "Bool" is the keyword for "System.Boolean". "bool" is not translated by Managed (Extensions for) C++ into "portable" CIL (MSIL, IL ... choose your favorite name). Notice that C# does recognize the keyword "bool" as "System.Boolean". So, there are differences, but the answer to your question is basically this: When writing code in Managed (Extensions for ...) C++ or any .NET language, when using non CTS types, portability is not assured (I have some reservations about portability at all with .NET, but thats for another day). Shabat Shalom, Kobi. __________________
It's actually a one time thing (it just happens alot). |
|
#5
|
||||
|
||||
Re: bool and BooleanQuote:
Quote:
Am i right to think that way?? __________________
Gravitation is not responsible for people falling in love. -Albert Einstein |
|
#6
|
||||
|
||||
Re: bool and BooleanQuote:
Try ... Quote:
Actually, "System.Int16" is referred by the keyword "short" "System.Int32" by "int" or "long" "System.Single" by "Float" I wish I could refer you to the table I'm working with, but it's a book I think you can find this table in msdn. Notice that some keywords start with lower-case letter and others with upper-case letter. If you are not sure, use the System. ... to verify that you are using CTS. Kobi. __________________
It's actually a one time thing (it just happens alot). |
|
#7
|
||||
|
||||
Re: bool and BooleanQuote:
__________________
Gravitation is not responsible for people falling in love. -Albert Einstein |
|
#8
|
||||
|
||||
Re: bool and BooleanQuote:
Yeahh, it doesn't work with VC++2005 either. I was referring to the table displayed in the book "Pro C# 2005 and the .NET 2.0 Platform", page 18. The correct keyword for "System.Boolean" ("System::Boolean") is "bool" in managed c++. The other part of my previous answer remains (if your compiler allows for usage of non-CTS types, CIL portability is not assured). Sorry to mislead you. Kobi. __________________
It's actually a one time thing (it just happens alot). |
|
#9
|
||||
|
||||
Re: bool and BooleanThank You
__________________
Gravitation is not responsible for people falling in love. -Albert Einstein |
Recent GIDBlog
Observations of Iraq by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| convert char to integer | blah | C++ Forum | 40 | 18-Aug-2005 14:08 |
| Detect Removable USB Device | Automatik | C Programming Language | 8 | 26-Jul-2005 04:36 |
| I need help implementing | kjc_13 | C++ Forum | 0 | 14-Feb-2005 16:00 |
| template comiling problems - need expert debugger! | crq | C++ Forum | 1 | 01-Feb-2005 21:26 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The