473,394 Members | 1,752 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

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 2120
Banfa
9,065 Expert Mod 8TB
You have not linked the object file created from stack.cpp into you exectuable?
Sep 17 '06 #2

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

Similar topics

15
by: Andrew | last post by:
Last night I was reading about implementing my own stack. The example given pushes items on and off the stack at the start and end of each procedure (ie. in a std module). What's not so clear is...
4
by: Chris Mabee | last post by:
Hello all, and Merry Christmas, I'm having a problem understanding an example of an array based implementation of a stack in a textbook of mine. The code in question is written below. The syntax...
19
by: Jim | last post by:
I have spent the past few weeks designing a database for my company. The problem is I have started running into what I believe are stack overflow problems. There are two tab controls on the form...
9
by: shine | last post by:
what is the difference between a heap and a stack?
5
by: Don Kim | last post by:
I copied this example off ECMA C++/CLI draft document, and it doesn't compile: #using <mscorlib.dll> using namespace System; public ref class Stack { public: Stack() { first = nullptr;
3
by: Jeremy | last post by:
While working with ASP.NET I've sometimes encountered errors in my applications, but I've always known exactly why I'm getting the error and have been able to fix it. So I've never needed to...
5
by: jbix | last post by:
We have a stack overflow happening. We are NOT doing any recusion. We do have an object being created in Global that is being handed the Context (which I assume is specific to the request thread). ...
24
by: arcticool | last post by:
I had an interview today and I got destroyed :( The question was why have a stack and a heap? I could answer all the practical stuff like value types live on the stack, enums are on the stack, as...
11
by: tom | last post by:
Hi! Im new to Python and doing exercise found from internet. It is supposed to evaluate expression given with postfix operator using Stack() class. class Stack: def __init__(self): self.items...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.