![]() |
|
#1
|
|||
|
|||
Passing a Stack to modify...Im not sure if i should be doing this by referance or what... but i want to pass a token *XML tag* to a stack through a function that checks for all my base cases. However i am having trouble passing in the stack and modifying it.. i think its still going out of scope... i just cant remember how to fix that.. i was thinking const stack<string>& stk, but thats if i wanted to modify it without modifying my primary correct? any help woudl be great
CPP / C++ / C Code:
CPP / C++ / C Code:
|
|||
|
#2
|
||||
|
||||
Re: Passing a Stack to modify...Quote:
You pass by const reference when you don't want the variable to be modified by the function. In your case, just pass it through non-const reference: CPP / C++ / C Code:
Best regards, Lucian __________________
Please read these Guidelines before posting on the forum "A person who never made a mistake never tried anything new." Einstein |
|
#3
|
|||
|
|||
Re: Passing a Stack to modify...Okay i did that it just isnt modifying the stack outside of the function. stack size not growing
|
|
#4
|
||||
|
||||
Re: Passing a Stack to modify...Quote:
Are you sure your call to push is reached? Step through the code with a debugger or output to the console the branches your program goes through. __________________
Please read these Guidelines before posting on the forum "A person who never made a mistake never tried anything new." Einstein |
|
#5
|
|||
|
|||
Re: Passing a Stack to modify...yeah i figured it out i forgot to return an int LOL... wow easy things get me... now i just got to finish working out my base cases and getting it to run correctly. Thanks your a wiz!!!
|
Recent GIDBlog
Problems with the Navy (Chiefs) by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Test driver code for stack class | glacier | C++ Forum | 2 | 03-Oct-2008 04:14 |
| clean up suggestions | dabigmooish | C++ Forum | 4 | 17-Nov-2006 07:30 |
| prime factors with stack | Kubu | C++ Forum | 5 | 16-Apr-2006 18:08 |
| Help With Stacks | penance | C Programming Language | 9 | 10-Oct-2005 09:25 |
| infix to postfix | Kacyndra | C++ Forum | 2 | 15-Aug-2005 11:44 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The