J
Jack
Hi,
I am stuck on a strange problem:
Here is my .h file.
#define DEFSIZE 10
template <class T>
public ref class cliQ{
public:
cliQ();
cliQ(int size);
void addToQ(int num);
T getItem();
private:
array<int>^ mQ;
int count;
};
here is cpp for the class:
#include "stdafx.h"
#include "cliQ.h"
using namespace System;
template <class T>
cliQ<T>::cliQ(){
Console::WriteLine("Setting up the Q with the Default
Const...");
mQ = gcnew array<int>(DEFSIZE);
count = 0;
}
template <class T>
cliQ<T>::cliQ(int size){
Console::WriteLine("Setting up the Q with the SIZE Const...");
mQ = gcnew array<int>(size);
count = 0;
}
template <class T>
void cliQ<T>::addToQ(int num){
//(*mQ)[count] = num;
count++;
}
template <class T>
T cliQ<T>::getItem(){
return 0;
}
and finally here is the driver (main)
#include "cliQ.h"
using namespace System;
int main(array<System::String ^> ^args)
{
Console::Write("Enter the size of the Queue: ");
cliQ<int> ^ q = gcnew
cliQ<int>(int:arse(Console::ReadLine()));
q->addToQ(5);
Console::Write("Press any key to continue...");
Console::ReadKey();
return 0;
}
When I try to compile this I get the following errors
Generating Code...
Linking...
myClr.obj : error LNK2020: unresolved token (06000001)
cliQ<int>::.ctor
myClr.obj : error LNK2020: unresolved token (06000002)
cliQ<int>::addToQ
C:\Documents and Settings\sdastour\My Documents\Visual Studio
2008\Projects\myClr\Debug\myClr.exe : fatal error LNK1120: 2
unresolved externals
I have looked on the net but can't find the reason for this.
Any ideas?
Thanks
I am stuck on a strange problem:
Here is my .h file.
#define DEFSIZE 10
template <class T>
public ref class cliQ{
public:
cliQ();
cliQ(int size);
void addToQ(int num);
T getItem();
private:
array<int>^ mQ;
int count;
};
here is cpp for the class:
#include "stdafx.h"
#include "cliQ.h"
using namespace System;
template <class T>
cliQ<T>::cliQ(){
Console::WriteLine("Setting up the Q with the Default
Const...");
mQ = gcnew array<int>(DEFSIZE);
count = 0;
}
template <class T>
cliQ<T>::cliQ(int size){
Console::WriteLine("Setting up the Q with the SIZE Const...");
mQ = gcnew array<int>(size);
count = 0;
}
template <class T>
void cliQ<T>::addToQ(int num){
//(*mQ)[count] = num;
count++;
}
template <class T>
T cliQ<T>::getItem(){
return 0;
}
and finally here is the driver (main)
#include "cliQ.h"
using namespace System;
int main(array<System::String ^> ^args)
{
Console::Write("Enter the size of the Queue: ");
cliQ<int> ^ q = gcnew
cliQ<int>(int:arse(Console::ReadLine()));
q->addToQ(5);
Console::Write("Press any key to continue...");
Console::ReadKey();
return 0;
}
When I try to compile this I get the following errors
Generating Code...
Linking...
myClr.obj : error LNK2020: unresolved token (06000001)
cliQ<int>::.ctor
myClr.obj : error LNK2020: unresolved token (06000002)
cliQ<int>::addToQ
C:\Documents and Settings\sdastour\My Documents\Visual Studio
2008\Projects\myClr\Debug\myClr.exe : fatal error LNK1120: 2
unresolved externals
I have looked on the net but can't find the reason for this.
Any ideas?
Thanks