注册 登录
编程论坛 C++ Builder

编译出错,这些类型我都不懂,怎么解决

ehszt 发布于 2016-09-02 17:16, 4374 次点击
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "Unit1.h"
#include "Unit2.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TMDIFrm *MDIFrm;
//---------------------------------------------------------------------------
__fastcall TMDIFrm::TMDIFrm(TComponent* Owner)
        : TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TMDIFrm::New1Click(TObject *Sender)
{
TChildFrm *NewChildFrm=new TChildFrm(this);
NewChildFrm->Caption=NewChildFrm;
}
//---------------------------------------------------------------------------
void __fastcall TMDIFrm::Open1Click(TObject *Sender)
{
if(OpenDialog1->Execute())
{
  TChildFrm *NewChildFrm=new TchildFrm(this);
  NewChildFrm->RichEdit1->Lines->LoadFromFile(OpenDialog1->FileName);
  NewChildFrm->Caption=ExtractFileName(OpenDialog1->FileName);
}
}
//---------------------------------------------------------------------------
Build
  [C++ Error] Unit1.cpp(21): E2034 Cannot convert 'TChildFrm *' to 'AnsiString'
  [C++ Error] Unit1.cpp(28): E2303 Type name expected
  [C++ Error] Unit1.cpp(28): E2034 Cannot convert 'int *' to 'TChildFrm *'
  [C++ Error] Unit1.cpp(28): E2141 Declaration syntax error
3 回复
#2
实际应用2016-10-01 16:58
这句错了
NewChildFrm->Caption=NewChildFrm;
Caption是字符串型,
NewChildFrm是类
型不一样,错了
#3
ehszt2016-10-01 20:26
回复 2楼 实际应用
已解决。
#4
return_02020-01-28 11:44

1