I am a C++ novice and I can’t figure out why i am having problem trying to compile my program. I have a small program. I AM RUNNING MICROSOFT VISUAL C++ 6.0. I will appreciate any help you guys can give!!
Here is the error I keep getting —>
ass121.obj : error LNK2001: unresolved external symbol “public: __thiscall bubble<int>::bubble<int>(int)” (??0?$bubble@H@@QAE@H@Z)
Debug/bubble.exe : fatal error LNK1120: 1 unresolved externals
Here is the Main program:
#include “iostream.h”
#include “bb.h”
int main()
{
bubble <int> can(5);
return 0;
}
Here is the Header file:
#ifndef TEST_H
#define TEST_H
template <class T>
class test {
public:
test(int = 1);
void print();
private:
T xx;
};
#endif
And Here is the function file:
#include <iostream.h>
#include “bb.h”
template< class x>
bubble<x>::bubble(int howmany)
{
howmany = (howmany > 0 && howmany < 15) ? howmany : 1;
HowMany = howmany;
numbers = new int[howmany];
for (int ww = 0; ww <= HowMany-1; ++ww)
numbers[ww] = 0;
getnumbers();
}
template<class x>
void bubble<x>::getnumbers()
{
for (int qq1 = 0; qq1 <= HowMany-1; ++qq1)
{
cout << endl;
cout << "Enter value: " << qq1 << " ";
cin >> numbers[qq1];
}
sort();
}
template<class x>
void bubble<x>::sort()
{
int temp;
for (int ss = 0; ss <= (HowMany - 2); ++ss)
{
for (int ww = 0; ww <= (HowMany -2); ++ww)
{
if (numbers[ww] >= numbers[ww + 1] )
{
temp = numbers[ww];
numbers[ww] = numbers[ww + 1];
numbers[ww + 1] = temp;
}
}
}
print();
}
template<class x>
void bubble<x>: rint()
{
for (int aa = 0; aa <= HowMany-1; ++aa)
{
cout << endl;
cout << numbers[aa];
}
}