I have problem defining array of a templated structure
Firstly there is one .h file which consists of a template class,all the definitions of functions are defined in this class itself because its a template class.
Code://test.h template<Data_T> class test { test test_func_1(const test &var); ..... }
There is another header file which has a structure "example" which should have a fucntion pointer as mentioned below,As "test" class is a template class i want this function pointer "fun_ptr" to behave like that
both of these version compiles successfully.Code://test2.h i can declare this structure like this (only one version,int only) 1. struct example { int a float b test<int> (*fun_ptr)(const test &a); } OR 2. template<typename Data_T> struct example { int a float b test<Data_T> (*fun_ptr)(const test &a); }
Now i want to declare an array of this templated structure e.g.
But compiler gives an error at this point. If i use "template<typename Data_T>" before "example_array[]" then also compiler gives error.Code:example example_array[] { {1,2,test_func_1}, //test_func_1 is defined in test.h file {3,4,test_func_2}, //test_func_2 is defined in test.h file };
Please tell me how to achieve this. Because of templates it is giving me errors.



LinkBack URL
About LinkBacks



