Dynamic memory allocation new new int; new Stash; new int[10]; new返回这个对象的指针 delete delete p; delete[]p; #include <iostream> using namespace std; class A { private: int i; public: A() { i = ; std::cout << "A::A()" << std::endl;…
一旦写了一个类,给它3个函数: 1default construtor 2virtual destructor 3copy constructor Constructions vs. assignment Every object is constructed once Every object should be destroyed once --Failure to invoke delete() --invoke delete() more than once Once an object…
Static in C++ Two basic meanings Static Storage --allocated once at a fixed address Visibility of a name --internal linkage Don't use static except inside functions and classes. Uses of "static" in C++ Static free functions----deprecated弃用 Stati…