470,571 Members | 2,358 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,571 developers. It's quick & easy.

Stack error

hello I am getting this strange error

Linking...
Cpp2.obj : error LNK2001: unresolved external symbol "public: bool __thiscall Stack::push(char const &)" (?push@Stack@@QAE_NABD@Z)
Debug/Cpp2.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.


I am not really sure why


My stack.ccp is this

/************************************************** ************************
#include "Stack.h"
#include <iostream>
using namespace std;

bool Stack::top( EType& Item ) const
{
bool Result = false;

if (Num > 0)
{
Item = Mem[Num-1];
Result = true;
}
return Result;
}

bool Stack::pop( EType& Item )
{
bool Result = false;

if (Num > 0)
{
Item = Mem[Num-1];
Num--;
Result = true;
}
return Result;
}

bool Stack::push( const EType& Item )
{
bool Result = false;

if (Num < STACK_MAX)
{
Mem[Num] = Item;
Num++;
Result = true;
}
return Result;
}

****************************************/

my stack.h is this
/******************************************
#ifndef STACK_
#define STACK_

const int STACK_MAX = 100;

typedef char EType;

class Stack
{
public:
Stack() { Num = 0; }
void reset() { Num = 0; }
bool is_empty() const { return Num == 0; }
bool is_full() const { return Num == STACK_MAX; }
bool top( EType& Item ) const;
bool pop( EType& Item );
bool push( const EType& Item );

private:

int Num;
EType Mem[STACK_MAX];
};
#endif

***************************************/

and when I try


#include <iostream>
#include "stack.h"
using namespace std;


void main()
{
Stack A;


A.push('a');
A.push('g');
}

I get that error, any ideas why?



}
Sep 17 '06 #1
1 1969
Banfa
9,065 Expert Mod 8TB
You have not linked the object file created from stack.cpp into you exectuable?
Sep 17 '06 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

15 posts views Thread by Andrew | last post: by
4 posts views Thread by Chris Mabee | last post: by
9 posts views Thread by shine | last post: by
5 posts views Thread by Don Kim | last post: by
3 posts views Thread by Jeremy | last post: by
5 posts views Thread by jbix | last post: by
24 posts views Thread by arcticool | last post: by
11 posts views Thread by tom | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.