Hi guys and gals,
Ok I'm cutting to the quik, here's what I want to do...
Can I create a class in a unit without any other unit or program being able to create another instance of that class?
The Idea is to create the instance in the initialization section and destroy it in the finalization section. However I don't want other units to be able to create other instances of the class, as far as they are concerned "uses uExample" then an instance is available... e.g.
type
tExample: class // I don't want other units to have the ability to create tExample.
public
msg: string
end;
var
MyExample: tExample; // I do want other units to have access to MyExample.
I have thought about a forward declaration to define the class in the implementation section or to put the constructor in the private defination of the class but OOP is fairly new to me so I thought, best ask the experts... What would you do