mirror of
https://github.com/isocpp/CppCoreGuidelines.git
synced 2024-03-22 13:30:58 +08:00
Merge pull request #1023 from marzojr/master
Fixing memory handling in E.5 example
This commit is contained in:
commit
6d5a219e66
|
@ -14704,8 +14704,8 @@ Not all member functions can be called.
|
|||
// if elem != nullptr then elem points to sz doubles
|
||||
public:
|
||||
Vector() : elem{nullptr}, sz{0}{}
|
||||
Vector(int s) : elem{new double}, sz{s} { /* initialize elements */ }
|
||||
~Vector() { delete elem; }
|
||||
Vector(int s) : elem{new double[s]}, sz{s} { /* initialize elements */ }
|
||||
~Vector() { delete [] elem; }
|
||||
double& operator[](int s) { return elem[s]; }
|
||||
// ...
|
||||
private:
|
||||
|
|
Loading…
Reference in New Issue
Block a user