BCS wrote:
Reply to Qian,
Hi All,
I am new to D community. I have some problems with TimeOfDay struct.
I have defined a class:
========================================================
class Test
{
TimeOfDay* getTime() {
return a_valid_timeofday_pointer;
}
Could you expand on this function? The rest looks good but if this
function is returning a pointer to something that then goes out of scope
(a local var for instance) than that would be the bug.
Hi, it was my fault.
My wrong code was:
========================================
public TimeOfDay* getTime() {
char[] timestring = "10:00:00"; // for test
FullDate fd;
parseTime(timestring, fd);
return *fd.val.time();
}
========================================
Today I have changed it to:
========================================
public TimeOfDay* getTime() {
char[] timestring = "10:00:00"; // for test
FullDate fd;
parseTime(timestring, fd);
TimeOfDay* ret = new TimdOfDay();
*ret = fd.val.time();
return ret;
}
========================================
Now it works properly.
--
Xu, Qian (stanleyxu)
http://stanleyxu2005.blogspot.com