C++ Do I have memory leak?
istream& operator>>(istream& in,hhh& hh){
double *arr,*temp;
int i=0;
char c;
c=in.peek();
while(c!='\n'){
if(i>=1){
temp=new double[++i];
for(int j=0;j<i-1;j++){
temp[j]=arr[j];
}
arr=temp;
}
else {
arr=new double[++i];
}
in>>arr[i-1];
c=in.peek();
}
hh.set(arr,i);
delete [] arr;
return in;
}
Do I have memory leak? I'm trying to figure out if i have but I'm not sure
about that, thanks for your help.
No comments:
Post a Comment