السلام عليكم ورحمة الله وبركاته ......
الموضوع بما فيه هو انني اريد القيام بعمل فئة تقوم بدور المجمع للارقام يعني List وقمت بكتابة هذا الكود :
#include<iostream.h>
#include<stdio.h>
#include<conio.h>
#include<string.h>
template<class No>
class List{
protected :
No* lst;
int Cursor;
List(){
this->lst= new No;
this->Cursor = 0;
};
};
template<class No>
class Accumulator : public List<class No>{
public :
void AddNo(No NewNo){
this->lst[this->Cursor] = NewNo;
};
No GetSum(){
No temp;
for(i = 0; i < this->Cursor - 1; i++)
temp+= this->lst;
return temp;
};
};
main(){
Accumulator x; // here u r gonna find an error
getchar();
};وعندما اقوم بعمل ترجمة للكود لا اجد اي خطأ , ولكن الخطأ يظهر عندما احاول ان اقوم بتعريف متغير جديد من الفئة داخل الدالة Main ففي ال ++VC تظهر رسالة الخطأ التالية :
use of class template requires template argument list
اما في ال borland فانه تظهر هذه الرسالة :
Invalid use of template
الرجاء مساعدتي جزاكم الله خيرا ........
اخوكم Dr.Pain
