【问题标题】:error C2664: 'CSchemaString::CSchemaString(LPCTSTR)' : cannot convert parameter 1 from 'int' to 'LPCTSTR' [closed]错误 C2664:“CSchemaString::CSchemaString(LPCTSTR)”:无法将参数 1 从“int”转换为“LPCTSTR”[关闭]
【发布时间】:2012-08-15 21:22:56
【问题描述】:

我收到以下错误:

错误 C2664:“CSchemaString::CSchemaString(LPCTSTR)”:无法将参数 1 从“int”转换为“LPCTSTR”

以下代码:

for(i=0;i<=tComponent.GetUpperBound();i++)
{       
    CSchemaString temp(i); // LINE AT WHICH ERROR OCCURS
    XComponent = ((Component *)tComponent.GetAt(i))->GetXMLCode(FOR_SAVING);               //AddName(*/temp +":"+*/ ((Component *)tComponent.GetAt(i))->GetName());
    XSave.AddPlant_Item(XComponent);

}

感谢任何帮助。

【问题讨论】:

  • XComponent的类型是什么?你在哪一行得到错误? XSave::AddPlant_Item的原型是什么?
  • 只是猜测,但 CSchemaString ctor 是否期望 char* 或其他类型的字符串?你给它i,我猜它是某种int

标签: c++ visual-studio visual-c++ compiler-errors visual-studio-2005


【解决方案1】:

您似乎试图创建temp 作为CSchemaString 传递i(这似乎是int)作为参数。如果我猜对了,这个类的可能构造函数是:

CSchemaString ()
CSchemaString (const tstring sValue)
CSchemaString (const TCHAR *szValue)
CSchemaString (const double nValue)
CSchemaString (const CSchemaType &rOther)

根据您的操作,您可能需要将i 转换为字符串或双精度才能满足CSchemaString 构造函数签名?

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-09-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-11-03
    • 1970-01-01
    相关资源
    最近更新 更多