I wanted to do a simple thing with templates and got surprised how not simple it is. I have got :
- An array which size is 9, let's say type const int *
I want it to pass it as an argument for an object construction, like so:
const int * myArray[9];
//filling array;
ObectType<int*> myObject(&myArray[0]);
With object constructor here :
template<class T>
class ObjectType
{
public:
ObjectType(const T * myArray) : myArrayMember(myArray) {};
const T * myArrayMember;
}
But I get the following error :
error: invalid conversion from ‘const int**’ to ‘int* const*’ [-fpermissive]
86 | ObectType<int*> myObject(&myArray[0]);
| ^~~~~~~~
| |
| const int**
Shouldn't const T * be replaced by const int** ? I have tried to keep it simple, the real code is more complicated. Tell me if you need some information.