Có bạn nào gặp trường hợp làm template class trong 1 file thì ok mà khi làm trong 1 project chia nhiều file thì bị lỗi kiểu thế này thì tư vấn giúp mình chút:
Bài này mình đã làm 2 file.h và .cpp thì ổn cả chỉ tới lúc gọi hàm main thì nó lỗi ngay chỗ StaticArray call;
#include "StaticArray.h"
#include <iostream>
#include <conio.h>
#include <stdexcept>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main(int argc, char** argv) {
StaticArray<float> call;
do {
try {
call.append(2.3);
call.append(2.4);
call.append(2.9);
call.append(3.0);
call.append(2.9);
cout << "\n\nShow The Original Array:\n\n";
call.showArray();
int pos = 2;
call.insert(pos, 2.33);
cout << "\n\nShow Array Is After Inserting:\n\n";
call.showArray();
cout << "\n" << call.element(2) << "\n";
cout << "\n" << call.element(100) << "\n";
} catch (exception const& e) {
}
try {
call.ecrase(20);
call.ecrase(2);
call.showArray();
} catch (exception const& e) {
}
break;
} while (true);
// getch();
return 0;
}


83% thành viên diễn đàn không hỏi bài tập, còn bạn thì sao?