【问题标题】:Function definition error, class has no member函数定义错误,类没有成员
【发布时间】:2014-11-22 03:24:52
【问题描述】:

我正在创建一个使用 Visual Studio 和 Windows 窗体计算工人工作时间的 UI 的初学者级项目。我的错误出现在以下函数中,我尝试将值分配给文本框。所有“ToDouble”都显示错误类“System::String”没有成员“ToDouble”,并且接近尾声(S“F”)显示标识符 S 未定义且预期)

void CalculateWeeklyHours(void)
         {
             double monday, tuesday, wednesday, thursday,
       friday, saturday, sunday, totalHours;

monday     = this->txtMonday->Text->ToDouble(0);
tuesday    = this->txtTuesday->Text->ToDouble(0);
wednesday  = this->txtWednesday->Text->ToDouble(0);
thursday   = this->txtThursday->Text->ToDouble(0);
friday     = this->txtFriday->Text->ToDouble(0);
saturday   = this->txtSaturday->Text->ToDouble(0);
sunday     = this->txtSunday->Text->ToDouble(0);

totalHours = monday + tuesday + wednesday + thursday +
             friday + saturday + sunday;
this->txtTotalHours->Text = totalHours.ToString(S"F");
             throw(gcnew System::NotImplementedException);
         }

完整代码在这里http://ideone.com/ySgxp1

c:\users\administrator\documents\visual studio 2012\projects\form1\form1\TimeSheet1.h(604): error C3921: Use of S-prefixed strings requires /clr:oldSyntax command line option 1> 使用 /clr 编译时,存在从字符串文字类型到 System::String^ 的隐式转换。如果需要避免歧义,请转换为 System::String^ 1>c:\users\administrator\documents\visual studio 2012\projects\form1\form1\TimeSheet1.h(594): error C2039: 'ToDouble' : is not a member of 'System::String' 1> c:\program files (x86)\reference assembly\microsoft\framework.netframework\v4.5\mscorlib.dll :参见“System::String”的声明 1>c:\users\administrator\documents\visual studio 2012\projects\form1\form1\TimeSheet1.h(595): error C2039: 'ToDouble' : is not a member of 'System::String' 1> c:\program files (x86)\reference assembly\microsoft\framework.netframework\v4.5\mscorlib.dll :参见“System::String”的声明 1>c:\users\administrator\documents\visual studio 2012\projects\form1\form1\TimeSheet1.h(596): error C2039: 'ToDouble' : is not a member of 'System::String' 1> c:\program files (x86)\reference assembly\microsoft\framework.netframework\v4.5\mscorlib.dll :参见“System::String”的声明 1>c:\users\administrator\documents\visual studio 2012\projects\form1\form1\TimeSheet1.h(597): error C2039: 'ToDouble' : is not a member of 'System::String' 1> c:\program files (x86)\reference assembly\microsoft\framework.netframework\v4.5\mscorlib.dll :参见“System::String”的声明 1>c:\users\administrator\documents\visual studio 2012\projects\form1\form1\TimeSheet1.h(598): error C2039: 'ToDouble' : is not a member of 'System::String' 1> c:\program files (x86)\reference assembly\microsoft\framework.netframework\v4.5\mscorlib.dll :参见“System::String”的声明 1>c:\users\administrator\documents\visual studio 2012\projects\form1\form1\TimeSheet1.h(599): error C2039: 'ToDouble' : is not a member of 'System::String' 1> c:\program files (x86)\reference assembly\microsoft\framework.netframework\v4.5\mscorlib.dll :参见“System::String”的声明 1>c:\users\administrator\documents\visual studio 2012\projects\form1\form1\TimeSheet1.h(600): error C2039: 'ToDouble' : is not a member of 'System::String' 1> c:\program files (x86)\reference assembly\microsoft\framework.netframework\v4.5\mscorlib.dll :参见“System::String”的声明 1>TimeSheet1.cpp(7):警告 C4829:main 函数的参数可能不正确。考虑'int main(Platform::Array^ argv)'

【问题讨论】:

    标签: c++ visual-studio visual-studio-2012 gcc


    【解决方案1】:

    【讨论】:

    • 我尝试了这种格式,但它不起作用。我粘贴了错误,看来我需要转换。
    猜你喜欢
    • 2011-01-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-07
    • 2013-09-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多