C++ 将字符串从托管列表框拉到char类型的类变量*

C++ 将字符串从托管列表框拉到char类型的类变量*,c++,string,pointers,listbox,char,C++,String,Pointers,Listbox,Char,这令人困惑。我理解指针,但跟踪引用是什么? 关于Wiki上的操作,指令不太清楚,更不用说我在ADV C++中从未教过。那么,如何将列表框中的项目放入我的类中呢? 另外,我可以得到一个简短的跟踪参考资料,以供将来参考? 我的表单有一个名为listbox2的列表框,其中包含一些数据 我的名为“ManifistOBJ”的类有一个名为“setFilename(char*)”的方法 现在在其他程序中,我可以很容易地将对象添加到“AddFilename”方法中,但是如何为跟踪引用添加对象呢 索法尔四号:

这令人困惑。我理解指针,但跟踪引用是什么? 关于Wiki上的操作,指令不太清楚,更不用说我在ADV C++中从未教过。那么,如何将列表框中的项目放入我的类中呢?
另外,我可以得到一个简短的跟踪参考资料,以供将来参考?

我的表单有一个名为listbox2的列表框,其中包含一些数据

我的名为“ManifistOBJ”的类有一个名为“setFilename(char*)”的方法

现在在其他程序中,我可以很容易地将对象添加到“AddFilename”方法中,但是如何为跟踪引用添加对象呢

索法尔四号:

DMManifest newmanifest = DMManifest();
         for(int i =1;i< listBox2->Items->Count;i++)
         {
             ManifistOBJ newobj = ManifistOBJ();
             System::String^ temp = listBox2->Items[i]->ToString();
             String temp1 = temp;//?
             char* temp2 = temp1.c_str();
             newobj.setFilename(temp2);
             newmanifest.push_back(newobj);
         }
DMManifest newmanifest=DMManifest();
对于(inti=1;iItems->Count;i++)
{
ManifistOBJ newobj=ManifistOBJ();
系统::字符串^temp=listBox2->Items[i]->ToString();
字符串temp1=temp;/?
char*temp2=temp1.c_str();
newobj.setFilename(temp2);
newmanifest.push_back(newobj);
}
有了字符串旁边的“^”,我无法取消引用它。我不知道该怎么做。 我可以让这个方法使用一个字符串^,但这会打乱我使用该库的其他程序。

#include
#include <msclr/marshal_cppstd.h>

System::String^ temp = listBox2->Items[i]->ToString(); 

std::string temp1 = msclr::interop::marshal_as< std::string >( temp );
系统::字符串^temp=listBox2->Items[i]->ToString(); std::string temp1=msclr::interop::marshal_as(temp);