You can do it at the Method level in delphi by declaring {$WRITEABLECONST ON} which esentially makes the const a static for the scope of the method it's delared in. I've never checked to see if it works between multiple instances of a class as I've generally only used it for singletons - like I've pasted in below.
Nahum. ----------------- {$WRITEABLECONST ON} class function TMouseCursorManager.Inst(const bFreeInstance : boolean = False) : TMouseCursorManager; const AMouseCursorManager : TMouseCursorManager = nil; begin if bFreeInstance then begin if assigned(AMouseCursorManager) then begin AMouseCursorManager.fAllowFree := True; FreeAndNil(AMouseCursorManager); end; Result := nil; end else begin if not assigned(AMouseCursorManager) then begin AMouseCursorManager := TMouseCursorManager.CreateInstance; AMouseCursorManager.Setup; end; Result := AMouseCursorManager; end; end; {$WRITEABLECONST OFF} > -----Original Message----- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On > Behalf Of Paul Heinz > Sent: Friday, 21 February 2003 14:35 p.m. > To: Multiple recipients of list delphi > Subject: RE: [DUG]: Delphi shared class data members? > > > Bob wrote: > > > Horrors! I'm in the process of familiarising myself with the new > > VB for .NET. In all fairness I must say its not too bad at all, > > though I've been having quiet gloats at the "new" language > > features ("ha! - had that in Delphi 1" etc.). I hadn't > > discovered any capabilities I wasn't familiar with in Delphi, > > until I came across VB's Shared class data members. > > > > They work like this: a data member is declared as Shared (scope > > can be specified normally) and all instances of the class and its > > descendants share the same variable - a bit like having a global > > with class scope. I can see how they'd be useful in some > situations. > > > > Quelle horreur, out-gunned by VB! I can't find an equivalent in > > Delphi - this is even worse than losing the Americas cup! Can > > anyone put me out of my misery and point out a feature of > > deepest, darkest Delphi where we can do the same? > > Actually, C++ has them too since day 1 - they're called > static or class > members in C++. > > Delphi has class functions and class methods, but not class members. > > You could 'fake' them by having a class function which > returns an object > instance which was kept in a private (i.e. implementation > section) unit > variable. > > In fact, we use this idiom in a number of places - the class > function even > operates as a singleton factory i.e. it creates an instance > the first time > it's called and returns that instance thereafter. > > This is sometimes quite handy for avoiding for resolving tricky > initialization order issues between cooperating classes in > different units. > > TTFN, > Paul. > > -------------------------------------------------------------- > ------------- > New Zealand Delphi Users group - Delphi List - > [EMAIL PROTECTED] > Website: http://www.delphi.org.nz > To UnSub, send email to: [EMAIL PROTECTED] > with body of "unsubscribe delphi" > Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/ > --------------------------------------------------------------------------- New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED] Website: http://www.delphi.org.nz To UnSub, send email to: [EMAIL PROTECTED] with body of "unsubscribe delphi" Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/