C++Builder Programming Forum
C++Builder  |  Delphi  |  FireMonkey  |  C/C++  |  Free Pascal  |  Firebird
볼랜드포럼 BorlandForum
 경고! 게시물 작성자의 사전 허락없는 메일주소 추출행위 절대 금지
C++빌더 포럼
Q & A
FAQ
팁&트릭
강좌/문서
자료실
컴포넌트/라이브러리
메신저 프로젝트
볼랜드포럼 홈
헤드라인 뉴스
IT 뉴스
공지사항
자유게시판
해피 브레이크
공동 프로젝트
구인/구직
회원 장터
건의사항
운영진 게시판
회원 메뉴
북마크
볼랜드포럼 광고 모집

C++빌더 Q&A
C++Builder Programming Q&A
[59666] Re:Re:Re:Re:Re:클래스만들때 에러요...
방콕폐인 [jeong325] 1195 읽음    2010-01-07 22:02
방콕폐인입니다.

볼포 에디터는 정말 별로군요...ㅡ.ㅡ;;

베이스 클래스인 TStringGrid에서 기본 생성자를 찾을 수 없다고 합니다.
인자가 없는 기본 생성자가 없으니 초기화를 하라고 하는 내용입니다.

생성자에서 초기화 해주세요.


아래와 같은 식이겠죠!?
class TGrid : public TStringGrid 
{ 
    public: 
                 TGrid(Classes::TComponent* AOwner) :  TStringGrid(AOwner)
                {
                }
}; 


이용태 님이 쓰신 글 :
: 제가 너무 성의 없이 글을 남겼나 봅니다. 죄송합니다.(__)
:
: 테스트를 다시 해봤습니다.
:
: Builder 6.0을 사용했구요..
:
: 빌더에서 기본적으로 제공해주는 TStringGrid를 상속받아 새로운 기능을 좀 넣어볼려고 합니다.
:
: 그래서 밑에처럼 코딩해서 컴파일해보면 다음과 같은 에러가 뜹니다.
: "Cannot find default constructor to initialize base class 'TStringGrid' "
:
: 왜 이런 에러가 뜨는거죠>?
:
:
:
:
:
:
:
: 아 글구
: 기본 생성자를 선언만 하고 구현하지 않았을 경우에는 다음과 같은 에러가 뜹니다.
:   [Linker Error] Unresolved external 'TMyGrid::' referenced from C:\PROGRAM FILES\BORLAND\CBUILDER6\PROJECTS\UNIT1.OBJ
:   [Linker Error] Unresolved external 'TMyGrid::TMyGrid()' referenced from C:\PROGRAM FILES\BORLAND\CBUILDER6\PROJECTS\UNIT1.OBJ
:
: 이건 당연히 뜨는겁니다.. 이 부분은 패스~~
:
:
: //.h
: //---------------------------------------------------------------------------
:
: #ifndef Unit1H
: #define Unit1H
: //---------------------------------------------------------------------------
: #include <Classes.hpp>
: #include <Controls.hpp>
: #include <StdCtrls.hpp>
: #include <Forms.hpp>
: #include <Grids.hpp>
: //---------------------------------------------------------------------------
: class TMyGrid : public TStringGrid
: {
:     public:
:         TMyGrid()
:         {
:
:         }
: };
:
: class TForm1 : public TForm
: {
: __published:    // IDE-managed Components
:     TStringGrid *StringGrid1;
: private:    // User declarations
: public:        // User declarations
:     __fastcall TForm1(TComponent* Owner);
:
:
:     TMyGrid *pGrid;
: };
: //---------------------------------------------------------------------------
: extern PACKAGE TForm1 *Form1;
: //---------------------------------------------------------------------------
: #endif
:
:
:
:
: //.cpp
: //---------------------------------------------------------------------------
:
: #include <vcl.h>
: #pragma hdrstop
:
: #include "Unit1.h"
: //---------------------------------------------------------------------------
: #pragma package(smart_init)
: #pragma resource "*.dfm"
: TForm1 *Form1;
: //---------------------------------------------------------------------------
: __fastcall TForm1::TForm1(TComponent* Owner)
:     : TForm(Owner)
: {
:     pGrid = new TMyGrid;
:
: }
: //---------------------------------------------------------------------------
:
:
:
: Lyn 님이 쓰신 글 :
: : 정말 동일한 에러인지 확인 해 보세요
: :
: : 이용태 님이 쓰신 글 :
: : : class TGrid : public TStringGrid
: : : {
: : :      public:
: : :                   TGrid()
: : :                    {
: : :                    }
: : :
: : :  };
: : :
: : : 이렇게 변경을 했어도 동일한 에러가 발생합니다.
: : :
: : : Lyn 님이 쓰신 글 :
: : : : 기본생성자를 선언만 하고 구현을 안했네요
: : : :
: : : : 이용태 님이 쓰신 글 :
: : : : : TStringGrid를 상속받아 TGrid라는 클래스를 만들려고 하는데요
: : : : :
: : : : : class TGrid : public TStringGrid
: : : : : {
: : : : :     public:
: : : : :                  TGrid();
: : : : : };
: : : : :
: : : : : 다음과 같은 에러가 납니다.
: : : : : "Complier could not generate default constructor for class 'TGrid'"
: : : : :
: : : : : 왜 그런건가요?
: : : : :
: : : : :
: : : : : //.h
: : : : : //---------------------------------------------------------------------------
: : : : :
: : : : : #ifndef Unit1H
: : : : : #define Unit1H
: : : : : //---------------------------------------------------------------------------
: : : : : #include <Classes.hpp>
: : : : : #include <Controls.hpp>
: : : : : #include <StdCtrls.hpp>
: : : : : #include <Forms.hpp>
: : : : : #include <ComCtrls.hpp>
: : : : : #include <Grids.hpp>
: : : : : //---------------------------------------------------------------------------
: : : : :
: : : : : class TGrid : public TStringGrid
: : : : : {
: : : : :     public:
: : : : :                  TGrid();
: : : : : };
: : : : :
: : : : :
: : : : :
: : : : : class TForm1 : public TForm
: : : : : {
: : : : : __published:    // IDE-managed Components
: : : : :     TStringGrid *StringGrid1;
: : : : :
: : : : : private:    // User declarations
: : : : : public:        // User declarations
: : : : :     __fastcall TForm1(TComponent* Owner);
: : : : :
: : : : :     TGrid *myGrid;
: : : : : };
: : : : : //---------------------------------------------------------------------------
: : : : : extern PACKAGE TForm1 *Form1;
: : : : : //---------------------------------------------------------------------------
: : : : : #endif
: : : : :
: : : : :
: : : : :
: : : : :
: : : : :
: : : : :
: : : : :
: : : : : //.cpp
: : : : : #include <vcl.h>
: : : : : #pragma hdrstop
: : : : :
: : : : : #include "Unit1.h"
: : : : : //---------------------------------------------------------------------------
: : : : : #pragma package(smart_init)
: : : : : #pragma link "ntabed"
: : : : : #pragma link "replist"
: : : : : #pragma resource "*.dfm"
: : : : : TForm1 *Form1;
: : : : : //---------------------------------------------------------------------------
: : : : : __fastcall TForm1::TForm1(TComponent* Owner)
: : : : :     : TForm(Owner)
: : : : : {
: : : : :     myGrid = new TGrid;
: : : : : }
: : : : : //---------------------------------------------------------------------------

+ -

관련 글 리스트
59658 클래스만들때 에러요... 이용태 1052 2010/01/07
59661         Re:Re:클래스만들때 에러요... 이용태 1039 2010/01/07
59663                 Re:Re:Re:Re:클래스만들때 에러요... 이용태 1115 2010/01/07
59666                     Re:Re:Re:Re:Re:클래스만들때 에러요... 방콕폐인 1195 2010/01/07
59671                         Re:Re:Re:Re:Re:Re:클래스만들때 에러요... 이용태 1080 2010/01/08
59676                             Re:Re:Re:Re:Re:Re:Re:클래스만들때 에러요... 방콕폐인 1048 2010/01/08
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.