The problem is the very last line:
datum.FromOADate(d);
DateTime::FromOADate
is actually a static member function that returns a DateTime
object. In C++ terms, you can think of it like a named constructor.
It does not initialize datum
like a normal member function would. What's confusing you is the fact that C++ allows you to call static members using an instance of the object. In C#, that would not be possible, and you would have gotten a compile-time error alerting you to the problem.
Write the code like this, and you will be fine:
COleDateTime m_dt;
m_ctrlDateTime.GetTime(m_dt);
double d = dt.m_dt;
System::DateTime datum = System::DateTime::FromOADate(d);
You could also do the following (but it would be similarly confusing):
COleDateTime m_dt;
m_ctrlDateTime.GetTime(m_dt);
double d = dt.m_dt;
System::DateTime datum;
datum = datum.FromOADate(d);