Hey!
I was writing my code, and just became wondering if I get a memory leak here. The program has a function which checks and creates a "Time" object, which simply includes integer values for hours and minutes. It returns the Time-object created to the main code. The thing is, I use the "new" command to make the object in the function, and what I've learned so far, I should use the "delete" command to delete the object and free the memory... or do I have to, in this kind of situation? Does the function free the memory automatically when the return statement is met? :)
In the function code:
...
Time* tempTime = 0;
if(ok)
tempTime = new Time(hours_int, minutes_int);
else
cout << "Error!" << endl;
return tempTime;
And, in the main:
Time* paramTime = 0;
paramTime = createTime(argv[4]);
if(paramTime != 0) {
ok4 = true;
cout << "OK4" << endl;
}
The code works perfectly, I'm just curious to know if it leaks or not. :)