
-----------------------------------
simonsayz
Sat Apr 11, 2009 1:17 pm

Implementing a template class Stack
-----------------------------------
I'm using Visual C++ 2008 Express Edition.
I'm getting the same three compile errors each time I compile this project. I don't know if my syntax for the template class is correct or not but I cannot figure it out. Any help or tips would be appreciated. 
The three errors are:
stack.h(10) : error C2143: syntax error : missing ';' before 'info = x.topPtr->info;
        ptr1 = x.topPtr->next;
        ptr2 = topPtr;
        while(ptr1 != NULL)
        {
            ptr2->next = new NodeType;
            ptr2 = ptr2->next;
            ptr2->info = ptr1->info;
            ptr1 = ptr1->next;
        }
        ptr2->next = NULL;
    }
}

template
void Stack::MakeEmpty()
{
	NodeType* tempPtr;
	while(topPtr != NULL) {
	tempPtr = topPtr;
    topPtr = topPtr->next;
    delete tempPtr;
	}
}

template
bool Stack::IsEmpty()
{
	return (topPtr = NULL);
}

template
bool Stack::IsFull()
{
	NodeType* location;
	location = new NodeType;
	if(location == NULL)
	 return true;
	else {
	 delete location;
     return false;
	}
}

template
int Stack::length()
{
	return size;
}

template
void Stack::Print()
{
	Reset();
	while(topPtr != NULL)
		{
			cout  info  next; // Moving thought the list
		}
}

template
void Stack::Pop(ItemType &x)
{
	NodeType* tempPtr;
	x = topPtr->info;
	tempPtr = topPtr;
	topPtr = topPtr->next;
	delete tempPtr;
	size--;
}

template
void Stack::Push(ItemType x)
{
	NodeType* location;
	location = new NodeType;
	location->info = x;
	location->next = topPtr;
	topPtr = location;
	size++;
}

template
void Stack::Reset()
{
	size = 0;
}

template
Stack::~Stack()
{
	MakeEmpty();
}

#endif 




Mod Edit: Fixed broken syntax tags. Code Here
