Link to home
Start Free TrialLog in
Avatar of Mike Littlewood
Mike LittlewoodFlag for United Kingdom of Great Britain and Northern Ireland

asked on

How do I free up a self made class correctly?

Ive made a really small class object in a unit (no form)

Type TQICheck = class
  Private
    MessageString: String;

    procedure CheckQValid;
    procedure CheckIValid;
  Public
     constructor Create;
     destructor Destroy; override;
     function QMessageMe: String;
     function IMessageMe: String;
  End;

2 public functions to return me a message string based on calculations within the private procedures.

constructor TQICheck.Create;
begin
  inherited Create;
  MessageString := '';
end;

destructor TQICheck.Destroy;
begin
  inherited Destroy;
end;

From another form when I click a button
procedure TForm_Main.TBB_QMessagesClick(Sender: TObject);
var
  OutputString: string;
  MyMessage: TQICheck;
begin
  MyMessage.Create;
  OutputString := MyMessage.QMessageMe;
  MessageDlg(OutputString, mtInformation, [mbOK], 0);
end;

Everything seems ok to me but obivously Im missing a basic line or something if I want free/destroy it (through the application)
When I shutdown my App I get lots of access violations.
I havent put any other code into the program apart from this.
Can someone tell me what I need to handle this correctly
ASKER CERTIFIED SOLUTION
Avatar of ceoworks
ceoworks

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ceoworks
ceoworks

You get access violations because you are trying to do something with a non-created class.

Cheers,

Oktay Sancak
Avatar of Mike Littlewood

ASKER

doh!

stupid mistake  :/

thanks
Don't think it's a little mistake..

Have a nice day,

Oktay