草庐IT

C++ 禁止自动初始化和销毁

如何抑制类型的自动初始化和销毁​​?Tbuffer[100]自动初始化buffer的所有元素,并在它们超出范围时销毁它们,这很棒,但这不是我想要的行为。#includestaticintcreated=0,destroyed=0;structS{S(){++created;}~S(){++destroyed;}};templateclassfixed_vector{private:Tm_buffer[KCount];public:fixed_vector(){//somewaytosuppresstheautomaticinitializationofm_buffer}~fixed_v