S
sandy
I have been given a class, stack to work with. I have created a class
called Job that I want to push on the stack.
I cannot seem to figure out why the push isn't working. (I know the
stack works, I have seen it demonstrated.)
The stack header looks like this:
<code>
#ifndef Stackll_h
#define Stackll_h
#include <stdlib.h>
// Stack: Header File
template <class Etype>
class Stack
{
public:
// Constructor
//
// Input : None
// Purpose: To create an empty Stack
// Output : None
Stack ( );
// Copy constructor
//
// Input : Stack S
// Purpose: To initialize Stack to S
// Output : None
Stack ( const Stack & S );
// Destructor
//
// Input : None
// Purpose: To free memory of Stack
// Output : None
~Stack ( );
// Copy assignment
//
// Input : Stack S
// Purpose: To assign S to current Stack
// Output : Current Stack
const Stack & operator= ( const Stack & S );
// Push
//
// Input : Element E
// Purpose: To place E on the top of Stack
// Output : 1 if successful; 0 otherwise
int Push ( const Etype & E );
// Pop
//
// Input : None
// Purpose: To delete the top element of Stack
// Output : 1 if successful; 0 otherwise
int Pop ( );
// Retrieve
//
// Input : None
// Purpose: To return the top element E of Stack
// Output : Element E and 1 if successful; 0 otherwise
int Retrieve ( Etype & E ) const;
// Empty
//
// Input : None
// Purpose: To check if Stack is empty
// Output : 1 if empty; 0 otherwise
int Empty ( ) const;
// Clear
//
// Input : None
// Purpose: To re-initialize Stack to empty
// Output : None
void Clear ( );
private:
// Data members
// A singly-linked Stack node
struct StackNode
{
Etype Element;
StackNode *Next;
// StackNode constructors
StackNode ( ) : Next ( NULL )
{ }
StackNode ( const Etype & E, StackNode *P = NULL ) :
Element ( E ), Next ( P )
{ }
};
// Pointer to the top of Stack
StackNode *Top;
};
#endif
</code>
My main where I am trying to Push onto the stack looks like this (part
of it anyway...)
<code>
//create a job
Job *thisJob;
char menuChoice;
int success = 0;
do
{
system("cls");
Stack<Job> *JC;
mainMenu();
cin >> menuChoice;
menuChoice = toupper(menuChoice);
cin.ignore(1, '\n');
switch(menuChoice)
{
case 'N':
//assign values
thisJob = new Job;
assignJobValues(thisJob);
success = JC->Push(&thisJob);
</code>
The error I get is: no matching function for call to
`Stack<Job>:ush(Job**)'
Thanks for your time!
called Job that I want to push on the stack.
I cannot seem to figure out why the push isn't working. (I know the
stack works, I have seen it demonstrated.)
The stack header looks like this:
<code>
#ifndef Stackll_h
#define Stackll_h
#include <stdlib.h>
// Stack: Header File
template <class Etype>
class Stack
{
public:
// Constructor
//
// Input : None
// Purpose: To create an empty Stack
// Output : None
Stack ( );
// Copy constructor
//
// Input : Stack S
// Purpose: To initialize Stack to S
// Output : None
Stack ( const Stack & S );
// Destructor
//
// Input : None
// Purpose: To free memory of Stack
// Output : None
~Stack ( );
// Copy assignment
//
// Input : Stack S
// Purpose: To assign S to current Stack
// Output : Current Stack
const Stack & operator= ( const Stack & S );
// Push
//
// Input : Element E
// Purpose: To place E on the top of Stack
// Output : 1 if successful; 0 otherwise
int Push ( const Etype & E );
// Pop
//
// Input : None
// Purpose: To delete the top element of Stack
// Output : 1 if successful; 0 otherwise
int Pop ( );
// Retrieve
//
// Input : None
// Purpose: To return the top element E of Stack
// Output : Element E and 1 if successful; 0 otherwise
int Retrieve ( Etype & E ) const;
// Empty
//
// Input : None
// Purpose: To check if Stack is empty
// Output : 1 if empty; 0 otherwise
int Empty ( ) const;
// Clear
//
// Input : None
// Purpose: To re-initialize Stack to empty
// Output : None
void Clear ( );
private:
// Data members
// A singly-linked Stack node
struct StackNode
{
Etype Element;
StackNode *Next;
// StackNode constructors
StackNode ( ) : Next ( NULL )
{ }
StackNode ( const Etype & E, StackNode *P = NULL ) :
Element ( E ), Next ( P )
{ }
};
// Pointer to the top of Stack
StackNode *Top;
};
#endif
</code>
My main where I am trying to Push onto the stack looks like this (part
of it anyway...)
<code>
//create a job
Job *thisJob;
char menuChoice;
int success = 0;
do
{
system("cls");
Stack<Job> *JC;
mainMenu();
cin >> menuChoice;
menuChoice = toupper(menuChoice);
cin.ignore(1, '\n');
switch(menuChoice)
{
case 'N':
//assign values
thisJob = new Job;
assignJobValues(thisJob);
success = JC->Push(&thisJob);
</code>
The error I get is: no matching function for call to
`Stack<Job>:ush(Job**)'
Thanks for your time!