我用NEW 新建一个自己的控件, 为何出错?
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit2.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
int f;
String fn;
if(OpenDialog1->Execute())
{
fn=OpenDialog1->FileName;
f=FileOpen(fn,fmOpenRead);
FileClose(f);
Memo1->Lines->LoadFromFile(fn); }
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
Memo2 = new TMemo2 ((TForm *) Sender) ;
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
#ifndef Unit2H
#define Unit2H
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <Dialogs.hpp>
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published: // IDE-managed Components
TButton *Button1;
TOpenDialog *OpenDialog1;
TMemo *Memo1;
void __fastcall Button1Click(TObject *Sender);
void __fastcall FormCreate(TObject *Sender);
private: // User declarations
TMemo * TMemo2;
public: // User declarations
__fastcall TForm1(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif
class TMemo2 : public TMemo
{ private:
unsigned int size ;
};
[C++ Error] Unit2.cpp(34): E2451 Undefined symbol 'Memo2'
[C++ Error] Unit2.cpp(34): E2303 Type name expected
[C++ Error] Unit2.cpp(34): E2379 Statement missing ;