|
단지 그것때문에.. Type name expected 에러를!!??
나중에 집에서 해봐야겠네요..
C/C++은 헤더파일을 인클루트 하는 개념이라 해더파일을 조금만 잘못다루면.. 에러를 내버리니..
----------------- 2009/ 3/ 25 오전 2 : 48 추가 내용 --------------
님의 말처럼 Unit1.h에 있던 '#include "Unit2.h"'와 Unit2.h에 있던 '#include "Unit1.h"'을 지우고
Unit1.h에는 class TForm2;를, Unit2.h에는 class TForm1;를 추가하고
각각의 소스파일에 '#include "Unit1.h"'과 '#include "Unit2.h"'를 추가하고 실행하니 컴파일 에러 없이 잘 되네요.
감사합니다.
김태선 님이 쓰신 글 :
: Unit1.h 를 다음과 같이.
:
: 두개의 클래스 교차 참조 문제입니다.
: 한쪽은 전체 프로토타입을 담지 말고,
: class TForm2;
: 과 같이 다만 그것이 클래스라는 것을 명시해주면 됩니다.
: 그러면 컴파일러가 알아서 인식합니다.
:
: //---------------------------------------------------------------------------
:
: #ifndef Unit1H
: #define Unit1H
: //---------------------------------------------------------------------------
: #include <Classes.hpp>
: #include <Controls.hpp>
: #include <StdCtrls.hpp>
: #include <Forms.hpp>
: //#include "Unit2.h" 이것 대신
: class TForm2; // 이걸로.
: //---------------------------------------------------------------------------
: class TForm1 : public TForm
: {
: __published: // IDE-managed Components
: TListBox *ListBox1;
: TButton *Button1;
: TButton *Button2;
: void __fastcall Button1Click(TObject *Sender);
: void __fastcall Button2Click(TObject *Sender);
: private: // User declarations
: TForm2 *frm;
: public: // User declarations
: __fastcall TForm1(TComponent* Owner);
: };
: //---------------------------------------------------------------------------
: extern PACKAGE TForm1 *Form1;
: //---------------------------------------------------------------------------
: #endif
:
: 나그네 님이 쓰신 글 :
: : 첨부한 소스는 간단한 폼간 값넘기기 소스인데요..
: : 주석처리한 부분
: : ' TForm1 *frm; ' <= 이부분
: : 에서 type name expeted 에러가 나네요.
: : 뭐가 잘못된거예요?
|