Взялся за изучение классов. Пишу:
- Код: Выделить всё
program Project1;
{$mode delphi}{$codepage utf8}{$H+}
uses
SysUtils, Windows;
type
MyClass = class(TObject)
private
sName : String;
iNumber : Integer;
eValue : Extended;
bState : Boolean;
public
constructor Create; overload;
constructor Create(nam : String); overload;
published
property Name : String read sName;
property Number : Integer read iNumber;
property Value : Extended read eValue;
property State : Boolean read bState;
end;
var
Class1, Class2 : MyClass;
constructor MyClass.Create;
begin
inherited Create;
sName := 'Default';
randomize;
iNumber := random(100);
randomize;
eValue := random + random(10);
bState := true;
end;
constructor MyClass.Create(nam : String);
begin
inherited Create;
sName := nam;
randomize;
iNumber := random(100);
randomize;
eValue := random + random(10);
bState := true;
end;
begin
Class1.Create;
Class2.Create('MyClass2');
MessageBox(0, PChar(Class1.Name), 'Name of Class1', 0);
end.
Программа компилируется, но вылетает с ошибкой
Project project1.exe raised exeption class 'External : SIGSEGV'
IDE указывает на строку
- Код: Выделить всё
MessageBox(0, PChar(Class1.Name), 'Name of Class1', 0);
IDE - Lazarus 0.9.29, LCL не используется
На стандартном FPC IDE та же хрень, только ошибка
An unhandled exeption occurred
EAccess Violation : Access violation
$00401631
Delphi подобное вообще не компилит
Незнаю в чём дело, помоему чего-то в классах напортачил
Подскажите, кто знает, пожалуйста, в чём дело...