|
This is a frustrated answer!
|
|
|
|
|
|
Because I want the following code(it's a part from a long one) search or check a required qau., is it avaliable in the array,I did it by the if/else statement ,and it runs,but I want it to be done by another select or conditional one,for example by(switch or )(if /else if )or another one.
Please answer it, because I did my try with( switch/case) but I failed to run it .
cout<<"\nEnter the Required_Qauntity:\n";
cin>>Required_Quantity;
if(Required_Quantity > x[index][1] || Required_Quantity <=0)
{cout<<"\nThe avaliable Quantity in the store is "<
|
|
|
|
|
select ? like in if and switch ?
if are best used for simple boolean decisions ( true, false ), and will become useless when you start using else if statements.
switch are best used for multiple decisions ( like making a decision that has many answers ).
There are some other types of select, I think lookup tables is one of them, usefull for fast access, but I'm not really familiar with it.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
Thanks, TOXCCT , Maximilien Lincourt, Prakash, VuNic, codito ergo sum ,for your considerable replays, what I mean is ,if I’ve a c++ program to search for a required quantity in a store I did it by if /else statement:
cout<<"\nEnter the Required_Qauntity:\n";<br />
cin>>Required_Quantity;<br />
if(Required_Quantity > x[index][1] || Required_Quantity <=0) <br />
{cout<<"\nThe avaliable Quantity in the store is "<<x[index][1]<<" part(s). Please ,enter a suitable quantity.\n";<br />
Goto f;<br />
}<br />
else <br />
cout<<"\nThe Required_Quantity is available in the store.\n";
Is there another way to make the same seach , and which one is the best to use it?
with thanks.
deema
-- modified at 8:34 Tuesday 31st January, 2006
|
|
|
|
|
deema,
what is that you want to do, I figured that you want to check a quantity against a item's available quantity,
What exactly are you stuck up with ?
|
|
|
|
|
I want the following code(it's a part from a long one) search or check a required qau., is it avaliable in the array,I did it by the if statement ,and it runs,but I want it to be done by another select or conditional one,for example by(switch or )(if /else )or another one.
Please answer it, because I did my try with( switch/case) but I failed to run it .
cout<<"\nEnter the Required_Qauntity:\n";<br />
cin>>Required_Quantity;<br />
if(Required_Quantity > x[index][1] || Required_Quantity <=0) <br />
{cout<<"\nThe avaliable Quantity in the store is "<<x[index][1]<<" part(s). Please ,enter a suitable quantity.\n";<br />
Goto f;<br />
}<br />
else <br />
cout<<"\nThe Required_Quantity is available in the store.\n";
|
|
|
|
|
use if(...) for validating multiple conditions,
There is no such thing as select in c++ , yeah there is switch statement.
-Prakash
|
|
|
|
|
Thanks, TOXCCT , Maximilien Lincourt, Prakash, VuNic, codito ergo sum ,for your considerable replays, what I mean is ,if I’ve a c++ program to search for a required quantity in a store I did it by if /else statement:
cout<<"\nEnter the Required_Qauntity:\n";
cin>>Required_Quantity;
if(Required_Quantity > x[index][1] || Required_Quantity <=0)
{cout<<"\nThe avaliable Quantity in the store is "<
|
|
|
|
|
you mean this? for multiple condtions, switch case is best.
it gives more readability.
VuNic
|
|
|
|
|
but you have to take not that the switch() works only for integer types...
never do this :
char* pszString = "Hello...";
switch (pszString) {
case "Hello":
break;
case "World":
break;
default:
}
this is bad !!!!!!
TOXCCT >>> GEII power [toxcct][VisualCalc 2.20][VCalc 3.0 soon...]
|
|
|
|
|
yeaa tox , that's really bad about it
VuNic
|
|
|
|
|
you can use strings in a switch
when the text is limited to 4 char
thats how the ftp, telnet and email server work,
they all use 4 letter commands to work
char szCmd[80];
unsigned long* pulCmd = &szCmd;
switch(*pulCmd)
{
case 0x706c6568:
Help();
break;
case 0x74697571:
Quit();
break;
case 0x6e65706f:
Open();
break;
}
codito ergo sum
|
|
|
|
|
good 'new's.
VuNic
|
|
|
|
|
Hi
The scenario here: Have a static member function defined in a base class which is being overridden in the derived class. This overloaded static member function needs to use a non static member variable.
So, as of now, trying not to change the signature of the static member function since it is part of the WTL - CDialogResize<t>.
As of now, workaround:
Since I am unable to pass the non static member as an parameter to the function without changing the signature of the function in the derived class as well as the base class, created a static member that stores the non static member value which I then use during the execution of the static function.
The problem here is that the value becomes static. So, even for a different instance of the same class, this values gets updated. This is not a preferred behavior in this case. Any tips would be appreciated.
Regards
Aruna
|
|
|
|
|
arunaas wrote: This overloaded static member function needs to use a non static member variable.
By definition, a static method cannot do that. It sounds like you're trying to work around a design problem by making more design problems, honestly.
--Mike--
Visual C++ MVP
LINKS~! Ericahist | NEW!! PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
|
|
|
|
|
Hi Mike
You are right. It is a design problem. I am trying to use the CDialogResize<t> WTL class as a base class. The static member function which I am trying to overload is GetDlgResizeMap() (Macro implemented)
I am deriving from CDialogResize<t> since I need to be able to make certain controls visible and some not visible at run time. Also, this was need to force paint on certain controls. The product was built using WTL. So, trying to use what is available and not trying to use new MFC or other classes.
If I just include the control as part of the macro map even though some of them are not visible(that actually implements the GetDlgresizeMap() function) CDialogResize does not understand that these controls are not visible and it starts trying to resize these which screws up the UI view. So, I need to manually either map these controls or not map them based on their visibility constraints.
So, I overloaded the #Define macro maps for BEGIN_DLGRESIZE_MAP and others to be able to map based on visibility constraints.
So, what else can I do? Please advise. Maybe , I can implement a new version of CDialogresize<t> from scratch....Do let me know your thoughts or comments...
By the way: Mike, your code snippets on the usage of CDialogResize<t> and other WTL classes were very helpful! Thanks for the same!
Regards
Aruna
|
|
|
|
|
such as:
UINT u=which_function_can_convert("FF00FF");
thx
A nice tool for optimizing your Microsoft html-help contents.
Includeh10
|
|
|
|
|
Use strtoul() .
"The greatest good you can do for another is not just to share your riches but to reveal to him his own." - Benjamin Disraeli
|
|
|
|
|
UINT u = strtoul("0xFF00FF", NULL, 16);
_outp(0x64, 0xAD);
and
__asm mov al, 0xAD __asm out 0x64, al
do the same... but what do they do??
(doesn't work on NT)
|
|
|
|
|
In a puzzle game, I dont know the size of the puzzle, how do I know the index number of the target element for swapping, at this moment I just know the index number of h is (hrow, hcol).
Am I wrong if I think this way?
e.g.
C | B
A | h
Assume the location of h at the keyboard is always on 5, then I hit 4 to swap h with A, hit 8 to swap B with h, and hit 7 to swap C with h.
For swapping A
tar_row = hrow;
tar_col = --hcol;
For swapping B
tar_row = --hrow;
tar_col = hcol;
For swapping C
tar_row = --hrow;
tar_col = --hcol;
Am I wrong?
|
|
|
|
|
eivanlo wrote: Am I wrong?
Maybe. However, to be completely sure, I would not rely on the operator -- precedence in an assignment, (such as tar_row = --hrow; ), but take two steps to do it (tar_row = hrow; hrow--; )
~RaGE();
|
|
|
|
|
Hi to all,
I made a deep search in this and other sites about serial communications management in Win32 (Win9X,2000,XP)
All the results leads to using ReadFile and the other file-style functions
But is any way to use interrupts (int of received char) on Windows?Must I create a device drivers?
Thanks to all
Cristian
|
|
|
|
|
misturas wrote: ReadFile
Mmmh .. .really ? What are you trying to achieve exactely ?
~RaGE();
|
|
|
|
|
Yes, sure. What is the problem with that ? Reading and writing data on the serial port is done with ReadFile and WriteFile.
|
|
|
|