我想了解如何在VS中使用Windows窗体应用程序,并且发现有问题。我习惯于基于控制台的应用程序。所以问题是:在文本框中显示
我有一个窗体,我想显示一个函数的结果,属于另一个类在文本框中,这是我想按下按钮时做的。例如,这是一个示例类:
#ifndef PRUEBA_H
#define PRUEBA_H
#include <string>
#include <iostream>
#include <iomanip>
using namespace std;
class Prueba
{
public:
void show()
{
cout<<"Thanks"<<endl;
}
};
#endif
,这是该按钮的代码:
#include "prueba.h"
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
Prueba *x = new Prueba();
textBox1->Text= System::Convert::ToString(x->show());
}
编译器给我这个错误
error C2665: 'System::Convert::ToString' : none of the 37 overloads could convert all the argument types
任何人都可以请帮助并发布正确的方式来显示功能的文本框?
我不知道这仍然是适用的,但我最后一次写了一个C++/CLI应用程序,我不得不使用'gcnew'而不仅仅是'new'如果我想垃圾收集对象。你将不得不做'Prueba^x = gcnew Prueba();'。 – dreamlax