Assume i have class A (fictional code)
Code:
type
TClassA = class
public
constructor Create(width, height: integer);
constructor Create;
// Seems to compile fine without adding word "overload"
end;
implementation
constructor TClassA.Create(width, height: integer);
begin
DoSomething(width, height);
end;
constructor TClassA.Create;
begin
Create(100, 100);
// Now what happens here? Am i creating an object that will not get
// assigned to any variable, basically a memory leak?
end;
How should i call the other constructor to refer self as its object? If there's a reserved word for this i don't know. "inherited" won't do as this case is not a parent class constructor.
edit: Well, my class seems to work with this technique so i suppose its all ok... It was a class for FrameBuffer, rendering to texture and showing that on screen works
Code:
constructor Create(const _texture: integer; _depth: boolean = false);
// This calls above Create with a newly created empty texture
constructor Create(const width, height: integer; transparency: boolean; _depth: boolean = false);
Edit2:
So what i guess is happening is that there is a world of difference with Object.Create and Class.Create. Object.Create will not allocate a new object but instead uses it as a normal procedure. Right?
Bookmarks