编译的时候出现如下错误,请帮我看一下啊

kittyhust 2006-04-27 08:54:53
Build
[C++ Error] tihuanlianxi.cpp(37): E2333 Class member '_fastcall TForm1::ReplaceDialog1Replace(TObject *)' declared outside its class
[C++ Error] tihuanlianxi.cpp(38): E2040 Declaration terminated incorrectly

程序的代码如下:
#include <vcl.h>
#pragma hdrstop

#include "tihuanlianxi.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button1Click(TObject *Sender)
{
if(OpenDialog1->Execute())
Memo1->Lines->LoadFromFile(OpenDialog1->FileName);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
ReplaceDialog1->Execute();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button3Click(TObject *Sender)
{
if(SaveDialog1->Execute())
Memo1->Lines->SaveToFile(SaveDialog1->FileName);
}
//---------------------------------------------------------------------------


void __fastcall TForm1::ReplaceDialog1Replace(TObject *Sender);
{
int SelPos;
Boolean flag;
int n;
TReplaceDialog *dlg=(Treplacedialog*)Sender;
SelPos=(Memo1->Lines->Text).Pos(dlg->FindText);
if(dlg->Options.Contains(frReplace))
{
if(SelPos>0)
{
Memo1->selstart=selPos-1;
Memo1->SelLength=(dlg->findtext).Length();
Memo1->selText=dlg->ReplaceText;
}
else
MessageDlg("not found"+dlg->findtext,mterror,TMsgDlgVButtons()<<mbOK,0);
}
if(dlg->Options.Contains(frReplaceAll))
{
if(SelPos>0)
flag=true;
else flag=false;
n=0;
if(flag)
{
while(SelPos>0)
{
Memo1->selstart=selPos-1;
Memo1->SelLength=(dlg->Findtext).Length();
Memo1->selText=dlg->ReplaceText;
SelPos=(Memo1->Lines->Text).Pos(dlg->FindText);
n++;
}
MessageDlg("全部替换完毕!共完成"+IntoStr(n)+"处替换。",mtInformation,TMsgDlgButtons()<<mbOK,0);
}
else
MessageDlg("not found"+dlg->FindText,mtError,TMsgDlgButton()<<mbOK,0);
}
}

为什么会出现哪种错误呢?我该如何去改,谢谢大侠们......
...全文
107 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
kittyhust 2006-04-27
  • 打赏
  • 举报
回复
是抄的,先练练手,只求看懂...
谢谢各位
BlueDeepOcean 2006-04-27
  • 打赏
  • 举报
回复
另外你的程序的错误太多了,抄的吧:改正如下:
void __fastcall TForm1::ReplaceDialog1Replace(TObject *Sender)
{
int SelPos;
Boolean flag;
int n;
TReplaceDialog *dlg=(TReplaceDialog*)Sender;
SelPos=(Memo1->Lines->Text).Pos(dlg->FindText);
if(dlg->Options.Contains(frReplace))
{
if(SelPos>0)
{
Memo1->SelStart=SelPos-1;
Memo1->SelLength=(dlg->FindText).Length();
Memo1->SelText=dlg->ReplaceText;
}
else
MessageDlg("not found"+dlg->FindText,mterror,TMsgDlgButtons()<<mbOK,0);
}
if(dlg->Options.Contains(frReplaceAll))
{
if(SelPos>0)
flag=true;
else flag=false;
n=0;
if(flag)
{
while(SelPos>0)
{
Memo1->SelStart=SelPos-1;
Memo1->SelLength=(dlg->FindText).Length();
Memo1->SelText=dlg->ReplaceText;
SelPos=(Memo1->Lines->Text).Pos(dlg->FindText);
n++;
}
MessageDlg(AnsiString("全部替换完毕!共完成"+IntToStr(n)+"处替换。"),mtInformation,TMsgDlgButtons()<<mbOK,0);
}
else
MessageDlg("not found"+dlg->FindText,mtError,TMsgDlgButtons()<<mbOK,0);
}
}

//这样,除了mterror未定以外,其他均OK。
BlueDeepOcean 2006-04-27
  • 打赏
  • 举报
回复
void __fastcall TForm1::ReplaceDialog1Replace(TObject *Sender);
你这个函数既然都已经有函数体了,为什么函数名后面还有分号,将分号去掉,就好了。
ccrun.com 2006-04-27
  • 打赏
  • 举报
回复
void __fastcall TForm1::ReplaceDialog1Replace(TObject *Sender);

这一行的后面不要加分号。
jone7319 2006-04-27
  • 打赏
  • 举报
回复
看错了,
void __fastcall TForm1::ReplaceDialog1Replace(TObject *Sender);
-->void __fastcall TForm1::ReplaceDialog1Replace(TObject *Sender) //去掉;

jone7319 2006-04-27
  • 打赏
  • 举报
回复
类成员定义于类外,在tihuanlianxi.h中加入 void __fastcall ReplaceDialog1Replace(TObject *Sender);

13,825

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder相关内容讨论区
社区管理员
  • 基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧