|
제가 너무 성의 없이 글을 남겼나 봅니다. 죄송합니다.(__)
테스트를 다시 해봤습니다.
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;
: : : : }
: : : : //---------------------------------------------------------------------------
|