Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Minor modification

Use unique_ptr to auto release for int array
  • Loading branch information...
commit 756cb412b5805c4bb321970a0c66163aaf112db5 1 parent be829bc
@elixir67 authored
Showing with 2 additions and 3 deletions.
  1. +2 −3 C++/Matrix/Matrix.cpp
View
5 C++/Matrix/Matrix.cpp
@@ -16,7 +16,6 @@
using namespace std;
#include <gtest\gtest.h>
-
class Vector;
// n Order Matrics
class Matrix
@@ -108,7 +107,7 @@ Vector * Matrix::Multiply(const Vector & v)
if(m_order != v.m_order)
return NULL;
- int * r = new int[m_order];
+ unique_ptr<int[]> r(new int[m_order]);
for(int i = 0; i < m_order; ++i)
r[i] = 0;
for(int row = 0; row < m_order; ++row)
@@ -119,7 +118,7 @@ Vector * Matrix::Multiply(const Vector & v)
for(int i = 0; i < m_order; ++i)
cout << r[i] << endl;
- Vector * rv = new Vector(r, m_order);
+ Vector * rv = new Vector(r.get(), m_order);
return rv;
}
Please sign in to comment.
Something went wrong with that request. Please try again.