我需要计算按钮之间的时差。当我通过改变做到这一点时,一切正常。但我需要在这里使用类((转移时我收到错误"没有合适的用户定义转换系统:TimeSpan从System:DateTime到存在"
和
1>source\repos\cash2\cash2\servtime.h(14): error C2440: 'initializing': cannot convert from 'System::TimeSpan' to 'System::DateTime'
1>source\repos\cash2\cash2\servtime.h(14): note: No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
我有班级服务时间:
ref class Servtime
{
public:
Servtime();
DateTime starttime;
DateTime finishtime;
DateTime getTime();
};
DateTime Servtime::getTime() {
DateTime timeee = finishtime.Subtract(starttime);
return timeee;
}
在另一个地方分配了开始时间
DateTime starttime = DateTime::Now;
点击按钮
Servtime ^ servertime = gcnew Servtime;
servertime->finishtime = DateTime::Now;
servertime->starttime = starttime;
我做错了什么?