DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   C++ (http://www.daniweb.com/forums/forum8.html)
-   -   Passing stack to a function (http://www.daniweb.com/forums/thread166099.html)

guest7 Jan 5th, 2009 12:55 am
Passing stack to a function
 
hi,

How can i pass a stack to the function. I am getting compilation error. Following is my code.
class circuit
{
        public:
        int append_and_file(stack<int> &);
        /* Some other variables defined */
}

int circuit::unroll()
{
        append_and_file(add_stack_ppi);
}
int circuit::append_and_file(stack<int> &stack_ref)
{
        int var=0;
        int num_clauses = 0;
        stack_ref.push(2);
}
Please tell me what is wrong.

Thanks,

MosaicFuneral Jan 5th, 2009 1:04 am
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?

Comatose Jan 5th, 2009 1:10 am
Re: Passing stack to a function
 
Missing ; after } for class prototype:
class circuit
{
public:
    int append_and_file(stack<int> &);
    /* Some other variables defined */
};

ArkM Jan 5th, 2009 4:56 am
Re: Passing stack to a function
 
Quote:

Originally Posted by Comatose (Post 770962)
Missing ; after } for class prototype:
class circuit
{
public:
    int append_and_file(stack<int> &);
    /* Some other variables defined */
};

Remark: this constuct called class definition in C++.

Comatose Jan 5th, 2009 8:58 am
Re: Passing stack to a function
 
:$ You are absolutely right.


All times are GMT -4. The time now is 5:40 am.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC