943,594 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 469
  • C++ RSS
Jan 5th, 2009
0

Passing stack to a function

Expand Post »
hi,

How can i pass a stack to the function. I am getting compilation error. Following is my code.
C++ Syntax (Toggle Plain Text)
  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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Junior Poster
guest7 is offline Offline
109 posts
since Mar 2008
Jan 5th, 2009
0

Re: Passing stack to a function

Did you declare unroll?
Do you have the error log?
Did you even bother to read the forum rules; that you have violated?
Reputation Points: 888
Solved Threads: 114
Nearly a Posting Virtuoso
MosaicFuneral is offline Offline
1,270 posts
since Nov 2008
Jan 5th, 2009
0

Re: Passing stack to a function

Missing ; after } for class prototype:
C++ Syntax (Toggle Plain Text)
  1. class circuit
  2. {
  3. public:
  4. int append_and_file(stack<int> &);
  5. /* Some other variables defined */
  6. };
Team Colleague
Reputation Points: 361
Solved Threads: 214
Taboo Programmer
Comatose is offline Offline
2,413 posts
since Dec 2004
Jan 5th, 2009
0

Re: Passing stack to a function

Click to Expand / Collapse  Quote originally posted by Comatose ...
Missing ; after } for class prototype:
C++ Syntax (Toggle Plain Text)
  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++.
Reputation Points: 1234
Solved Threads: 347
Postaholic
ArkM is offline Offline
2,001 posts
since Jul 2008
Jan 5th, 2009
0

Re: Passing stack to a function

You are absolutely right.
Team Colleague
Reputation Points: 361
Solved Threads: 214
Taboo Programmer
Comatose is offline Offline
2,413 posts
since Dec 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Change button background
Next Thread in C++ Forum Timeline: C++ File IO Operations





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC