I'm trying to create a DLL file with the following code: the header:
#pragma once
#ifdef PRO_ONE
#define DLLFUNC _declspec(dllexport)
#else
#define DLLFUNC _declspec(dllimport)
#endif
#include <vector>
#include <string>
using namespace std;
template <class T>
class interAlgo {
public:
virtual void summaryRanges(vector<int>& nums) = 0;
virtual T getAlgoFirst() = 0;
};
template <class T>
class firstSul : public interAlgo<T> {
private:
T resultVec;
public:
firstSul();
void summaryRanges(vector<int>& nums);
T getAlgoFirst();
};
template <class T>
extern "C" DLLFUNC interAlgo<T>* _cdecl CreateAlgoObject(); //issue is here!!!!!!!!!!!!!!!!
cpp file:
#include "pch.h"
#include "progone.h"
#include <sstream>
#include <map>
template<class T>
firstSul<T>::firstSul()
{
}
template <class T>
void firstSul<T>::summaryRanges(vector<int>& nums) {
this->resultVec.clear();
const int n = nums.size();
int i = 0;
for (int j = 0; j < n; ++j) {
string range = "";
if (j + 1 == n || nums[j] + 1 != nums[j + 1]) {
if (i == j) {
range = to_string(nums[i]);
}
else {
range = to_string(nums[i]) + "->" + to_string(nums[j]);
}
resultVec.push_back(range);
i = j + 1;
}
}
}
template <class T>
T firstSul<T>::getAlgoFirst() {
return this->resultVec;
}
template <class T>
interAlgo<T>* CreateAlgoObject() {
return new firstSul<T>();
}
the error's are: E0335 linkage specification is not allowed C2955 'interAlgo': use of class template requires template argument list
Why is this happening, and how can the problem be fixed?