您基于“ unsigned int”对类进行模板化。例:template <unsigned int N>class MyArray{ public: private: double data[N]; // Use N as the size of the array};int main(){ MyArray<2> a1; MyArray<2> a2; MyArray<4> b1; a1 = a2; // OK The arrays are the same size. a1 = b1; // FAIL because the size of the array is part of the // template and thus the type, a1 and b1 are different types. // Thus this is a COMPILE time failure. }