unresolved external symbol

I am getting the following error in this program:
1
2
Text1.obj : error LNK2001: unresolved external symbol "void __cdecl pop(int * const,int &)" (?pop@@YAXQAHAAH@Z)
Text1.obj : error LNK2001: unresolved external symbol "int __cdecl push(int * const,int &,int)" (?push@@YAHQAHAAHH@Z)


I haven't been able to find any near solution.
Please help me out. Thanks...

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
  #include<iostream>
using namespace std;
void pop(int[], int&);
int push(int[],int&,int);
void Display(int[],int);
//-Wunused Variable

int main(){

    cout<<"\t\t\tHello World\n\n";
    int info,resr,stacks[50],top=-1;
   // int s=50;
    char c='y';
    while(c=='y'||c=='Y'){
        cout<<"Please enter data: "; cin>>info;
        resr=push(stacks[0],top,info);
                if(resr!=-1)
                {
                    cout<<"Result unsuccessful\n";
                    return 0;
                }else{
                    cout<<"Your element has been pushed. Displaying your elements\n";
                    Display(stacks,top);
                }
        cout<<"Do you want to enter more elements? ";
        cin>>c;
    }
    cout<<"Do you want to delete elements?";
    cin>>c;
    while(c=='y'||c=='Y'){
        pop(stacks,top);
        cout<<"Now displaying your data: ";
        cout<<endl;
        Display(stacks,top);
    }
    return 0;
}

int push(int st[],int top,int info){
    if(top==49){
        return -1;
    }else{
        top++;
        st[top]=info;
        return info;
    }
    return 0;
}
void pop(int st[],int top){
    if(top==-1){
        cout<<"Underflow!\n";
    }else{
        top--;
    }
}

void Display(int st[],int top){
    for(int i=top; i>-1;--i)
        cout<<st[i]<<endl;
}
Your declaration and definitions are not the same.

1
2
3
4
5
void pop(int[], int&); // note the &
int push(int[],int&,int); // note the &

void pop(int st[],int top){ // note the lack of &
int push(int st[],int top,int info){ // note the lack of & 
JEEEEEE.

hate it when I make those silly mistakes. Life would be easier if compilers were a little more specific.
If you want more specific compilers, program in java :p
Topic archived. No new replies allowed.