I am getting the error "error C2228: left of '.push' must have class/struct/union" when I try to push a random double onto the stack.
Here's my driver...
#include <iostream>
#include <string>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include "DynStack.h"
using namespace std;
int main()
{
double dblCatch; //holds values popped off the stack
float floatCatch; //holds values popped off the stack
int size; //size of a stack
//create two different DynStack objects with different data types
DynStack<double> doubleStack();
DynStack<float> floatStack();
cout << "Enter number of doubles to put in the stack: ";
cin >> size;
for (int count = 0; count < size; count++)
{
srand (time(NULL));
doubleStack.push((double)rand() / ((double)(RAND_MAX)+(double)(1)));
}
return 0;
}
Here's my DynStack header...
#ifndef DYNSTACK_H
#define DYNSTACK_H
#include <iostream>
#include <cstdlib>
using namespace std;
template <class T>
class DynStack
{
private:
//structure for stack nodes
struct StackNode
{
T value; //value in the node
StackNode *next; //pointer to the next node
};
StackNode *top; //pointer to the stack top;
public:
//constructor
DynStack()
{
top = NULL;
}
//destructor
~DynStack();
//stack operations
void push(T);
void pop(T &);
void isEmpty();
};
#endif