Click here to Skip to main content
15,923,051 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: basetsd.h? Pin
DaveE9th18-Jul-03 7:45
DaveE9th18-Jul-03 7:45 
GeneralRe: basetsd.h? Pin
Bob Stanneveld18-Jul-03 8:10
Bob Stanneveld18-Jul-03 8:10 
GeneralRe: basetsd.h? Pin
John M. Drescher18-Jul-03 8:39
John M. Drescher18-Jul-03 8:39 
Questionbasetsd.h? Pin
DaveE9th17-Jul-03 20:14
DaveE9th17-Jul-03 20:14 
AnswerRe: basetsd.h? Pin
Andrew Walker17-Jul-03 20:18
Andrew Walker17-Jul-03 20:18 
GeneralTemplate Class App-Wizard Parsing Error Pin
Wonderful Cow17-Jul-03 18:40
Wonderful Cow17-Jul-03 18:40 
GeneralRe: Template Class App-Wizard Parsing Error Pin
John M. Drescher17-Jul-03 19:04
John M. Drescher17-Jul-03 19:04 
GeneralRe: Template Class App-Wizard Parsing Error Pin
Wonderful Cow17-Jul-03 19:37
Wonderful Cow17-Jul-03 19:37 
I checked but it appears OK. This is kind of a strange problem. My template class is in a header file, because for whatever reason, the compiler would not accept the template class seperated into two files. I tried putting it only in a implementation file, but I get a "unexpected end of file" compiler error. As is, it works, but I can't use class wizard to add functions to the view class, where the stacks are declared. Makes me want to pull my "fricking" hair out.

Below is my stack class, maybe there is something I am missing.

#include <cstddef>
#include <new>

template <class ItemType>
struct NodeType;

template<class ItemType>
class StackType
{
public:
StackType();
void MakeEmpty();
bool IsFull() const;
bool IsEmpty() const;
int LengthIs() const;
void Push(ItemType item);
void Pop(ItemType& item);
private:
NodeType<ItemType>* topPtr;
int length;
};

//implementation
template <class ItemType>
struct NodeType
{
ItemType info;
NodeType<ItemType>* next;
};

template<class ItemType>
StackType<ItemType>::StackType()
{
topPtr = NULL;
length = 0;
}

template<class ItemType>
void StackType<ItemType>::Pop(ItemType& item)
{
if (IsEmpty())
throw CString("PopOnEmptyStack");//PopOnEmptyStack();
else
{
NodeType<ItemType>* tempPtr;
tempPtr = topPtr;
item = topPtr ->info;
//cout<<item<<endl;
topPtr = topPtr->next;
delete tempPtr;
length--;
}
}

template<class ItemType>
bool StackType<ItemType>::IsFull() const
{
NodeType<ItemType>* location = NULL;
location = new NodeType<ItemType>;

if(location != NULL)
{
delete location;
return false;
}
else
{
return true;
}
}

template <class ItemType>
void StackType<ItemType>::Push(ItemType newItem)
{
if (IsFull())
throw CString("PushOnFullStack");//PushOnFullStack();
else
{
NodeType<ItemType>* ptr;
ptr = new NodeType<ItemType>;
ptr->info = newItem;
ptr->next = topPtr;
topPtr = ptr;
length++;
}
}

template <class ItemType>
void StackType<ItemType>::MakeEmpty()
{
NodeType<ItemType>* tempPtr;

while (topPtr != NULL)
{
tempPtr = topPtr;
topPtr = topPtr->next;
delete tempPtr;
}

length = 0;
}

template <class ItemType>
bool StackType<ItemType>::IsEmpty() const
{
return (topPtr == NULL);
}

template <class ItemType>
int StackType<ItemType>::LengthIs() const
{
return length;
}


Missing: Wonder Cow, LooseScrew, Clark, Screwage, AlterEgo, packingascwdriver, Rob Irtson, IB, George Harrison? I weep. (please, never ask...to painful.)
GeneralRe: Template Class App-Wizard Parsing Error Pin
John M. Drescher17-Jul-03 19:57
John M. Drescher17-Jul-03 19:57 
GeneralRe: Template Class App-Wizard Parsing Error Pin
Andrew Walker17-Jul-03 20:03
Andrew Walker17-Jul-03 20:03 
GeneralRe: Template Class App-Wizard Parsing Error Pin
John M. Drescher17-Jul-03 20:07
John M. Drescher17-Jul-03 20:07 
GeneralRe: Template Class App-Wizard Parsing Error Pin
Andrew Walker17-Jul-03 20:13
Andrew Walker17-Jul-03 20:13 
GeneralRe: Template Class App-Wizard Parsing Error Pin
John M. Drescher17-Jul-03 19:49
John M. Drescher17-Jul-03 19:49 
GeneralRe: Template Class App-Wizard Parsing Error Pin
Wonderful Cow17-Jul-03 21:35
Wonderful Cow17-Jul-03 21:35 
GeneralRe: Template Class App-Wizard Parsing Error Pin
Wonderful Cow17-Jul-03 21:09
Wonderful Cow17-Jul-03 21:09 
Questionhow to get the wm_keydown msg Pin
gucy17-Jul-03 15:27
gucy17-Jul-03 15:27 
GeneralGetting application name which is using serial port Pin
haritadala17-Jul-03 14:45
haritadala17-Jul-03 14:45 
GeneralRe: Getting application name which is using serial port Pin
Iain Clarke, Warrior Programmer17-Jul-03 22:26
Iain Clarke, Warrior Programmer17-Jul-03 22:26 
GeneralExecute functions in context of other thread Pin
Mike_V17-Jul-03 13:37
Mike_V17-Jul-03 13:37 
GeneralRe: Execute functions in context of other thread Pin
Michael Dunn17-Jul-03 13:53
sitebuilderMichael Dunn17-Jul-03 13:53 
GeneralRe: Execute functions in context of other thread Pin
Mike_V17-Jul-03 14:00
Mike_V17-Jul-03 14:00 
GeneralRe: Execute functions in context of other thread Pin
Michael Dunn17-Jul-03 14:42
sitebuilderMichael Dunn17-Jul-03 14:42 
GeneralTool windows in an MDI App Pin
XboxHomebrewer17-Jul-03 13:15
XboxHomebrewer17-Jul-03 13:15 
GeneralFunction template Pin
RalfPeter17-Jul-03 12:27
RalfPeter17-Jul-03 12:27 
GeneralRe: Function template Pin
John M. Drescher17-Jul-03 12:45
John M. Drescher17-Jul-03 12:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.