In file included from program3.cpp:6:
Machines.h:19: 'Array' is used as a type, but is not defined as a type.
Machines.h:26: declaration of `class DataType'
Machines.h:24: shadows template parm `class DataType'
Machines.h:28: too many template parameter lists in declaration of `
linkedlistStack'
Machines.h:31: data member `info' cannot be a member template
Machines.h:32: non-template type `Node' used as a template
Machines.h:32: ISO C++ forbids declaration of `next' with no type
Machines.h:32: data member `next' cannot be a member template
Machines.h:35: ISO C++ forbids declaration of `Stacklink' with no type
Machines.h:45: non-template type `Node' used as a template
Machines.h:45: ISO C++ forbids declaration of `front' with no type
Machines.h:45: data member `front' cannot be a member template
Machines.h:46: non-template type `Node' used as a template
Machines.h:46: ISO C++ forbids declaration of `back' with no type
Machines.h:46: data member `back' cannot be a member template
Machines.h:47: non-template type `Node' used as a template
Machines.h:47: ISO C++ forbids declaration of `header' with no type
Machines.h:47: data member `header' cannot be a member template
In file included from machine.cpp:2,
from program3.cpp:7:
Machines.h:8: redefinition of `class bottleArrayStack<DataType>'
Machines.h:8: previous definition of `class bottleArrayStack<DataType>'
Machines.h:19: 'Array' is used as a type, but is not defined as a type.
Machines.h:26: declaration of `class DataType'
Machines.h:24: shadows template parm `class DataType'
Machines.h:28: too many template parameter lists in declaration of `
linkedlistStack'
Machines.h:31: data member `info' cannot be a member template
Machines.h:32: non-template type `Node' used as a template
Machines.h:32: ISO C++ forbids declaration of `next' with no type
Machines.h:32: data member `next' cannot be a member template
Machines.h:35: ISO C++ forbids declaration of `Stacklink' with no type
Machines.h:45: non-template type `Node' used as a template
Machines.h:45: ISO C++ forbids declaration of `front' with no type
Machines.h:45: data member `front' cannot be a member template
Machines.h:46: non-template type `Node' used as a template
Machines.h:46: ISO C++ forbids declaration of `back' with no type
Machines.h:46: data member `back' cannot be a member template
Machines.h:47: non-template type `Node' used as a template
Machines.h:47: ISO C++ forbids declaration of `header' with no type
Machines.h:47: data member `header' cannot be a member template
In file included from program3.cpp:7:
machine.cpp:54: ISO C++ forbids declaration of `Stacklink' with no type
machine.cpp:54: no `int linkedlistStack<DataType>::Stacklink()' member function
declared in class `linkedlistStack<DataType>'
machine.cpp:54: template definition of non-template `int
linkedlistStack<DataType>::Stacklink()'
machine.cpp:59: confused by earlier errors, bailing out
In file included from machine.cpp:2:
Machines.h:19: 'Array' is used as a type, but is not defined as a type.
Machines.h:26: declaration of `class DataType'
Machines.h:24: shadows template parm `class DataType'
Machines.h:28: too many template parameter lists in declaration of `
linkedlistStack'
Machines.h:31: data member `info' cannot be a member template
Machines.h:32: non-template type `Node' used as a template
Machines.h:32: ISO C++ forbids declaration of `next' with no type
Machines.h:32: data member `next' cannot be a member template
Machines.h:35: ISO C++ forbids declaration of `Stacklink' with no type
Machines.h:45: non-template type `Node' used as a template
Machines.h:45: ISO C++ forbids declaration of `front' with no type
Machines.h:45: data member `front' cannot be a member template
Machines.h:46: non-template type `Node' used as a template
Machines.h:46: ISO C++ forbids declaration of `back' with no type
Machines.h:46: data member `back' cannot be a member template
Machines.h:47: non-template type `Node' used as a template
Machines.h:47: ISO C++ forbids declaration of `header' with no type
Machines.h:47: data member `header' cannot be a member template
machine.cpp:54: ISO C++ forbids declaration of `Stacklink' with no type
machine.cpp:54: no `int linkedlistStack<DataType>::Stacklink()' member function
declared in class `linkedlistStack<DataType>'
machine.cpp:54: template definition of non-template `int
linkedlistStack<DataType>::Stacklink()'
machine.cpp:59: confused by earlier errors, bailing out
#include <iostream>
#include <string>
#include <sstream>
#include "Machines.h"
usingnamespace std;
int main()
{
bottleStack bottle;
linkedStack Can;
int x;
char type;
int selection;
struct soda
{
string name;
char type;
float price;
} drink;
do
{
cout<<"\n Menu (order 1-4, 5 exit)"<<"\n";
cout<<"\n 0thers: Exit";
cout<<"\n 1: Add another soda to the machine ";
cout<<"\n 2: Buy a soda ";
cout<<"\n 3: Find a soda by name ";
cout<<"\n 4: How much is the soda ";
cout<<"\n 5: QUIT";
cout<<"\n\n Enter a choice : ";
cin >> selection;
if (selection = 1)
{
cout << "What is the name of the soda you would like to add?"<< endl;
cin >> drink.name;
cout << "Is the soda a Can or a Bottle?"<< endl;
cin >> drink.type;
cout << "How much is the soda? (Value between $0.0 and $1.25)" << endl;
cin >> drink.price;
bottle.push(drink);
}
if (selection = 2)
{
cout << "Would you like a bottle(B) or Can(C)?"<< endl;
cin >> type;
if (type = 'B' || 'b')
bottle.pop(drink);
else
Can.poplink(drink);
}
if (selection = 5)
cout << "quit" << endl;
} while(selection != 5)
return 0;
}
Basically what im trying to do is imitate a soda machine using an linked list and an array based stack. I tried to make a template for each so that a user could just use an object as a data type and store drinks in the machine.
The array based stack named "bottlestackarray" would store all bottle data in an stack.
The linked list one was to be used if the type was determined to be 'c' or can.
Line 20 of the header file I put as a private member an array of "data type elements called elements.