我想了解如何在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