자꾸 violation access error 어쩌구 저쩌구가 나는데..
어느 부분이 틀렸는지를 모르겠거든요..
약간 의심나는 부분이라면
project 파일내에서는 다른 클래스를 참조할수 없나요?
폼없는 프로그램을 만들려고 이렇게 해 보았는데 도무지 안되네요..
혹시 폼 없는 프로그램 만드는 법 알고 계신분 도와주세요..
그럼..
program Project1;
uses
Dialogs,
Unit1 in 'Unit1.pas';
var
ha: Thaha;
begin
ha.setString('hum');
showMessage(''+ha.GetString+'');
end.
unit Unit1;
interface
type
THaha = class
private
str1 : string;
public
procedure SetString(str2 : string);
function GetString: string;
end;
implementation
function Thaha.GetString: string;
begin
Result := self.str1;
end;
procedure Thaha.SetString(str2 :string);
begin
self.str1 := str2;
end;
end.
ha: Thaha;
begin
ha.setString('hum');
showMessage(''+ha.GetString+'');
end.
THaha 클래스의 인스턴스인 ha를 생성하는 부분이 없는 것 같은데요.
ha := new Thaha;
정도가 들어가야 할 것 같네요.
델초보2 wrote:
> 자꾸 violation access error 어쩌구 저쩌구가 나는데..
> 어느 부분이 틀렸는지를 모르겠거든요..
> 약간 의심나는 부분이라면
> project 파일내에서는 다른 클래스를 참조할수 없나요?
>
> 폼없는 프로그램을 만들려고 이렇게 해 보았는데 도무지 안되네요..
> 혹시 폼 없는 프로그램 만드는 법 알고 계신분 도와주세요..
>
> 그럼..
>
> program Project1;
> uses
> Dialogs,
> Unit1 in 'Unit1.pas';
>
> var
> ha: Thaha;
> begin
> ha.setString('hum');
> showMessage(''+ha.GetString+'');
> end.
>
> unit Unit1;
>
> interface
>
> type
> THaha = class
> private
> str1 : string;
> public
> procedure SetString(str2 : string);
> function GetString: string;
> end;
>
> implementation
>
> function Thaha.GetString: string;
> begin
> Result := self.str1;
> end;
>
> procedure Thaha.SetString(str2 :string);
> begin
> self.str1 := str2;
> end;
>
> end.