Hello,
Sorry for the poor title,I'm new to OOP so I don't know what is the term for what I need to do.
I have, say, 10 different Objects that inherit one Object.They have different amount and type of class members,but all of them have one property in common - Visible.
type TSObject=class(TObject);
protected
Visible:boolean;
end;
type
TObj1=class(TSObject)
private
a:integer;
...(More members)
end;
TObj2=class(TSObject)
private
b:String;
...(More members)
end;
...(Other 8 objects)
For each of them I have a variable.
var Obj1:TObj1;
Obj2:TObj2;
Obj3:TObj3;
....(Other 7 objects)
Rule 1: Only one object can be initialized at a time(others have to be freed) to be visible.
For this rule I have a global variable
var CurrentVisibleObj:TSObject; //Because they all inherit TSObject
Finally there is a procedure that changes visibility.
procedure ChangeObjVisibility(newObj:TSObject);
begin
CurrentVisibleObj.Free; //Free the old object
CurrentVisibleObj:=newObj; //assign the new object
CurrentVisibleObj:= ??? //Create new object
CurrentVisibleObj.Visible:=true; //Set visibility to new object
end;
There is my problem,I don't know how to initialize it,because the derived class is unknown(TObj1,TObj2,Tobj3...Which one?).
How do I do this?
I simplified the explanation,in the project there are TFrames each having different controls and I have to set visible/not visible the same way(By leaving only one frame initialized).
Sorry again for the title,I'm very new to OOP.