Passing stack to a function

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Mar 2008
Posts: 102
Reputation: guest7 is an unknown quantity at this point 
Solved Threads: 0
guest7 guest7 is offline Offline
Junior Poster

Passing stack to a function

 
0
  #1
Jan 5th, 2009
hi,

How can i pass a stack to the function. I am getting compilation error. Following is my code.
  1. class circuit
  2. {
  3. public:
  4. int append_and_file(stack<int> &);
  5. /* Some other variables defined */
  6. }
  7.  
  8. int circuit::unroll()
  9. {
  10. append_and_file(add_stack_ppi);
  11. }
  12. int circuit::append_and_file(stack<int> &stack_ref)
  13. {
  14. int var=0;
  15. int num_clauses = 0;
  16. stack_ref.push(2);
  17. }
Please tell me what is wrong.

Thanks,
Last edited by Ancient Dragon; Jan 5th, 2009 at 3:34 pm. Reason: add code tags
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 949
Reputation: MosaicFuneral is just really nice MosaicFuneral is just really nice MosaicFuneral is just really nice MosaicFuneral is just really nice MosaicFuneral is just really nice 
Solved Threads: 92
MosaicFuneral's Avatar
MosaicFuneral MosaicFuneral is offline Offline
Posting Shark

Re: Passing stack to a function

 
0
  #2
Jan 5th, 2009
Did you declare unroll?
Do you have the error log?
Did you even bother to read the forum rules; that you have violated?
"Jedenfalls bin ich überzeugt, daß der Alte nicht würfelt."
"I became very sensitive to what will happen to all this and all of us." -Two geniuses named Albert
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 2,413
Reputation: Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough 
Solved Threads: 211
Team Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Taboo Programmer

Re: Passing stack to a function

 
0
  #3
Jan 5th, 2009
Missing ; after } for class prototype:
  1. class circuit
  2. {
  3. public:
  4. int append_and_file(stack<int> &);
  5. /* Some other variables defined */
  6. };
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 2,001
Reputation: ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of 
Solved Threads: 343
ArkM's Avatar
ArkM ArkM is offline Offline
Postaholic

Re: Passing stack to a function

 
0
  #4
Jan 5th, 2009
Originally Posted by Comatose View Post
Missing ; after } for class prototype:
  1. class circuit
  2. {
  3. public:
  4. int append_and_file(stack<int> &);
  5. /* Some other variables defined */
  6. };
Remark: this constuct called class definition in C++.
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 2,413
Reputation: Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough 
Solved Threads: 211
Team Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Taboo Programmer

Re: Passing stack to a function

 
0
  #5
Jan 5th, 2009
You are absolutely right.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC