gpt4 book ai didi

visual-studio-2010 - 如何在 C++/CLI 中定义字符串数组?

转载 作者:行者123 更新时间:2023-12-01 09:34:37 25 4
gpt4 key购买 nike

这有什么问题:

我得到了所有 5 个定义的这些错误:

 error C3698: 'System::String ^' : cannot use this type as argument of 'gcnew'
error C2512: 'System::String::String' : no appropriate default constructor available



array<String^>^ arr = gcnew array<String^>
{
gcnew String^ "Madam I'm Adam.",
gcnew String^ "Don't cry for me,Marge and Tina.", //error C2143: syntax error : missing '}' before 'string' AND error C2143: syntax error : missing ';' before 'string'
gcnew String^ "Lid off a daffodil.",
gcnew String^ "Red lost Soldier.",
gcnew String^ "Cigar? Toss it in a can. It is so tragic."
}

最佳答案

你不应该在数组初始化器中使用 gcnew:

array<String^>^ arr = gcnew array<String^> {
"Madam I'm Adam.",
"Don't cry for me,Marge and Tina.",
"Lid off a daffodil.",
"Red lost Soldier.",
"Cigar? Toss it in a can. It is so tragic."
};

关于visual-studio-2010 - 如何在 C++/CLI 中定义字符串数组?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10546250/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com