| MAQAH (20) | |||||
|
The question is about a basic concept , Why cant we use the variable
Queue::Queue(int s) // constructor { maxSize = s;
front = 0; rear = -1; nItems = 0; } cant we use it as
same thing happens in stacks also , and I dont know the exact reason why we do this way .. any one ? | |||||
|
|
|||||
| MAQAH (20) | ||
ok guys , my self found an answer . I think yes we can use the variable
| ||
|
|
||
| pogrady (410) | |
|
You should also check if variable s is zero. I'm not sure why you can't use the variable s. If you wanted to know the array size later you can always use size t = sizeof int / sizeofqueArray[0]; or store the size on a global variable. | |
|
|
|
| Framework (3116) | |||||
Maybe because "s" is local to "Queue::Queue( )", and beyond that, "s" will not exist, so you have to store the value of "s" in "maxSize" to extend the scope of "s"'s value.
Yes, you can, and I don't see a reason not to. Wazzak | |||||
|
Last edited on
|
|||||