Delphi/Lazarus: Class with different Create Methods
Question by Guest | 2013-11-15 at 11:57
I do not do programming for a long time and I've just dared creating my first class. For this, I have found a simple base frame on the Internet, which is working great.
The only problem is that I would like to write two different create methods for my class. Namely, it should be possible to create the class with different and various parameters.
Until now, it is only possible to me to program a single create method within my class. Is it even possible to create several create methods within one class or am I imagining something impossible?
Related Topics
Delphi/Lazarus: Command Line Parameter Tutorial Part 1: Sending
Tutorial | 0 Comments
Lazarus: Load File as Byte Array and save Byte Array as File
Tutorial | 0 Comments
Delphi/Lazarus: Create TabSheet on PageControl dynamically
Tutorial | 0 Comments
Delphi: Global Treatment of Errors (Exceptions)
Tutorial | 0 Comments
Delphi/Lazarus: How to set up a Link to a Website in an Application
Tutorial | 0 Comments
Delphi: Multiline Caption for TLabel (at Run Time and Design Time)
Tutorial | 1 Comment
HTML: Difference between ID and CLASS
Info | 0 Comments
Important Note
Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.
Participate
Ask your own question or write your own article on askingbox.com. That’s how it’s done.
This is no problem and readily possible.
As an example, here is a small class provding a simple counter.
As you can see, we are providing two different Create Methodes. Both can be used to create an instance of the class:
When declaring multiple different Create Methods, it is important to write the key word "overload" behind the declaration. Otherwise, the declaration is just the same like declaring single Create Methods.
2013-11-17 at 18:26