N
nifsmith
Hi
I am trying to learn about Queues and use templates at the same time. I
have written the following code and I am getting a link error, stating
"unresolved external symbol, "int__cdecl adsq::QInitialise<struct
adsq:ata>(struct adsq::Head<struct adsq:ata> *)"
-----------adsq.h file
#ifndef ADSQ_H
#define ADSQ_H
#include <iostream>
namespace adsq
{
struct Data
{
int First;
int Second;
};
template <class T> struct Node
{
T itsData;
Node<T>* nextNode;
};
template <class T> struct Head
{
Node<T>* itsHead;
Node<T>* itsTail;
long Count;
];
template <class R> int QInitialise(Head<R>* theQueueHead);
//Specialiasation
//template <> int QInitialise(Head<Data>* theQueueHead);
}
-----------adsq.cpp
#include "adsq.h"
template <class R> int adsq::QInitialise(Head<R>* theQueueHead)
{
theQueueHead->itsHead = 0;
theQueueHead->itsTail = 0;
theQueueHead->Count = 0;
}
//template <> int adsq::QInitialise(Head<Data>* theQueueHead)
//{
//theQueueHead->itsHead = 0;
//theQueueHead->itsTail = 0;
//theQueueHead->Count = 0;
//}
-----------driver.h
#ifndef DRIVER_H
#define DRIVER_H
#include <iostream>
#include "adsq.h"
#endif
-----------driver.cpp
#include "driver.h"
using namespace std;
using namespace adsq;
int main()
{
Head<Data> *pH = new Head<Data>;
int i = QInitialise(pH); //This will only work if you implement
//the specialisation
}
I have tried to keep this as simple for myself as possible as I am still
new to this C++ game.
I have tried the FAQ and googling, but I can't find anything specific to
passing templates to templates
Can you pass a template to another template as I am trying to do above,
or is it not possible. Must I use specialisations, if I do how will I
know ever type that a user may put into my queue?
The above was created in a VS 2003 unmanaged project.
TYIA
nifsmith
I am trying to learn about Queues and use templates at the same time. I
have written the following code and I am getting a link error, stating
"unresolved external symbol, "int__cdecl adsq::QInitialise<struct
adsq:ata>(struct adsq::Head<struct adsq:ata> *)"
-----------adsq.h file
#ifndef ADSQ_H
#define ADSQ_H
#include <iostream>
namespace adsq
{
struct Data
{
int First;
int Second;
};
template <class T> struct Node
{
T itsData;
Node<T>* nextNode;
};
template <class T> struct Head
{
Node<T>* itsHead;
Node<T>* itsTail;
long Count;
];
template <class R> int QInitialise(Head<R>* theQueueHead);
//Specialiasation
//template <> int QInitialise(Head<Data>* theQueueHead);
}
-----------adsq.cpp
#include "adsq.h"
template <class R> int adsq::QInitialise(Head<R>* theQueueHead)
{
theQueueHead->itsHead = 0;
theQueueHead->itsTail = 0;
theQueueHead->Count = 0;
}
//template <> int adsq::QInitialise(Head<Data>* theQueueHead)
//{
//theQueueHead->itsHead = 0;
//theQueueHead->itsTail = 0;
//theQueueHead->Count = 0;
//}
-----------driver.h
#ifndef DRIVER_H
#define DRIVER_H
#include <iostream>
#include "adsq.h"
#endif
-----------driver.cpp
#include "driver.h"
using namespace std;
using namespace adsq;
int main()
{
Head<Data> *pH = new Head<Data>;
int i = QInitialise(pH); //This will only work if you implement
//the specialisation
}
I have tried to keep this as simple for myself as possible as I am still
new to this C++ game.
I have tried the FAQ and googling, but I can't find anything specific to
passing templates to templates
Can you pass a template to another template as I am trying to do above,
or is it not possible. Must I use specialisations, if I do how will I
know ever type that a user may put into my queue?
The above was created in a VS 2003 unmanaged project.
TYIA
nifsmith