Bonjour,

j'ai un souci pour créer un héritage d'un template. Ma classe ressemble beaucoup à la classe 'array' de boost et je n'arrive pas à en hériter... J'utilise visual studio pour la compilation.

ma classe :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
template <class T, std::size_t N> class CMyArray
{
public:
	T m_array[N];
	static const unsigned int m_static_size = N;
 
	// functions
	inline std::size_t size() const { return m_static_size; }
	inline const T* data() const { return m_array; }
	inline void assign(const T * _array)
	{ memcpy((*this).m_array, _array, sizeof(T)*N);	}
 
	// operators
	T& operator[](int);
	T operator[](int) const;
	template<class U> CMyArray& operator=(const CMyArray<U, N>& a)
	{
		memcpy((*this).m_array, a.m_array, sizeof(U)*N);
		return (*this);
	}
	int operator==(const CMyArray<T, N>&) const;
	int operator!=(const CMyArray<T, N>&) const;
 
	// friends
	template<class T2, std::size_t N2> friend std::ostream& operator<<( std::ostream&, const CMyArray<T2, N2>&);
};
 
// main de test
int main()
{
       CMyArray<int, 4> var = {0, 1, 2, 3};
       return 0;
}
Lorsque j'essai d'en hériter par exemple une classe : CMyPoint<...>, je ne peux plus faire mon initialisation comme avec la classe CMyArray<...> avec la liste d'arguements.

Quelqu'un sait ou ça coince ?