델파이/파스칼 : 다른 프로토 타입과 생성자를 오버로드
- 으로 어떤 경우를위한 특별한 생성자를 TForm 클래스의 하위 클래스를 만들려고 해요
및
- 호환성을 유지하는 기본 생성자 현재 코드.
interface TfrmEndoscopistSearch = class(TForm) public /// original constructor kept for compatibility constructor Create(AOwner : TComponent); overload; override; /// additional constructor allows for a caller-defined base data set constructor Create(AOwner : TComponent; ADataSet : TDataSet; ACaption : string = ''); overload; end;
그것은 작동하는 것 같다,하지만 난 항상 컴파일러 경고 얻을 :
이 내가 지금 가지고있는 코드입니다
[Warning] test.pas(44): Method 'Create' hides virtual method of base type 'TCustomForm'
- 추가 "과부하;" 두 번째 생성자는 컴파일되지 않습니다. "[Error] test.pas (44) : 'Create'선언은 이전 선언과 다릅니다."
- 두 번째 생성자를 오류 또는 경고없이 컴파일하지만 런타임에 액세스 위반으로 종료됩니다 (모든 멤버 변수는 nil 임). 다음과 같이 두 번째
overload
전에reintroduce
를 추가
bango! "reintroduce"키워드는 정확히 필요한 것입니다. 원래의 생성자는 데이터 세트를 적절한 기본값으로 설정하기 때문에 필요합니다. –