السلام عليكم ورحمة الله وبركاتة
بارك الله فيكم جميعاً
ماهو الخطاء في الكود التالي حيث انة عند استخدام template تظهر المشكلة وعندما امسح Template من الكود يشتغل تمام
ملف الـ header
#ifndef h_stacktype
#define h_stacktype
template <class Type>
class stacktype
{
Type *list;
int top;
int stacksize;
public:
stacktype( int size=10);
};
#endif
ملف ccp
#include "stdafx.h"
#include "stacktype.h"
template <class Type>
stacktype<Type>::stacktype(int size)
{
top=0;
stacksize=size;
list =new Type [stacksize];
}
ملف الدالة الرئيسية main
#include "stdafx.h"
#include "stacktype.h"
#include <iostream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
stacktype<char> s(20);
return 0;
}
حيث ان الرسالة التي تظهر عند تنفيذ الكود هي
unresolved external symbol "public: __thiscall stacktype<char>::stacktype<char>(int)" (??0?$stacktype@D@@QAE@H@Z) referenced in function _wmain

