多謝 fffhghgjh 給個尋找的方向.
找到之前有篇類的文章 http://delphi.ktop.com.tw/topic.php?topic_id=53379
修改過後程式已經能執行了.如下.
unit1.cpp
//--------------------------------------------------------------------------- #include
#pragma hdrstop #include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
node *mkbintree(char *treestring,struct node *root);
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{ }
//--------------------------------------------------------------------------- void __fastcall TForm1::Button1Click(TObject *Sender)
{
char chr[1000] = "abcd";
node *bintree;
bintree = NULL;
mkbintree(chr,bintree);
}
//---------------------------------------------------------------------------
node * __fastcall TForm1::mkbintree(char *treestring,struct node *root)
{
.
Edit1->Text = "abc";
.
.
.
} unit1.h
//--------------------------------------------------------------------------- #ifndef Unit1H
#define Unit1H
//---------------------------------------------------------------------------
#include
#include
#include
#include <Forms.hpp>
//---------------------------------------------------------------------------
struct node
{
char data;
struct node *left,*right;
};
class TForm1 : public TForm
{
__published: // IDE-managed Components
TButton *Button1;
TEdit *Edit1;
void __fastcall Button1Click(TObject *Sender);
private: // User declarations
public: // User declarations __fastcall TForm1(TComponent* Owner); node * __fastcall mkbintree(char *treestring,struct node *root);
};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif 只不過有個問題,如果將struct node弄在class TForm1,似乎會有錯誤產生,要像 http://delphi.ktop.com.tw/topic.php?topic_id=53379 文章內說的,放在class TForm1之前才可以,這樣是對的嗎?