|
From: Jason H. <jas...@bt...> - 2002-04-22 17:41:39
|
The queueElement idetifier has no relevance outside of the template class scope. Inside of the class
the compiler will sustitute the name for the relevent type that was specified for creation, in this
case it is int. You can treat the identifier as something similar to a typedef which is targeted at
that particular class.
There may also be a problem with the ostream friend declaration, but I'm not sure. I'd have to do
some research to figure it out.
Jason.
----- Original Message -----
From: <Wal...@va...>
To: <dev...@li...>
Sent: Monday, April 22, 2002 4:03 PM
Subject: [Dev-C++] templates
I am getting these errors/warnings, need some help please.
Walt
(Embedded image moved to file: pic06617.pcx)
This in .cpp file:
#include <iostream.h>
#include <stdlib.h>
#include <ctype.h>
#include "Temp.h"
void ShowCommands ();
int main ()
{
char command;
Queue<int>q;
queueElement item;
This is in the Temp.h file:
#include <iostream.h>
#include <stdlib.h>
#ifndef QUEUE
#define QUEUE
const int MAX=401;
int i;
template <class queueElement>
class Queue
{
private:
queueElement myArray[MAX];
int myFront;
int myBack;
public:
friend ostream& operator << (ostream&,
Queue<queueElement> &);
Queue(){myFront=0;myBack=0;};
bool empty();
void addQ(queueElement);
queueElement front();
void removeQ();
bool full();
};
#endif //end of class queu
"This e-mail message is intended only for the use of the named
recipient(s).
The information contained therein may be confidential or privileged, and
its
disclosure or reproduction is strictly prohibited. If you are not the named
recipient, please return it immediately to its sender at the above address
and destroy it."
|