C++动态内存分配 素材狗 1970-01-01 08:00:00 文章分类:C/C++实例代码 点击数:2次 文章标签 #include iostreamusing namespace std;class Box {public:Box() { cout Constructor called! endl; 编程学习网为您整理以下代码实例,主要实现:C++动态内存分配,希望可以帮到各位朋友。 #include <iostream> using namespace std; class Box { public: Box() { cout << "Constructor called!" <<endl; } ~Box() { cout << "Destructor called!" <<endl; } }; int main() { Box* myBoxArray = new Box[4]; delete [] myBoxArray; // Delete array return 0; } 复制代码 上一篇:C++条件编译 下一篇:C++类模板 相关文章