VB6 classes have no parameterized constructors. What solution have you chosen for this? Using factory methods seems like the obvious choice, but surprise me!
相关问题
- What uses more memory in c++? An 2 ints or 2 funct
- How Does WebSphere Choose the Classloading Order i
- Convert VB's Val to Java?
- Invalid Picture In Visual basic 6
- Store data and global variables using the Applicat
相关文章
- Java call constructor from constructor
- NameError: name 'self' is not defined, eve
- What CursorAdapter have I to use?
- Reading (with Filesystem.FileGet) VB6 record file
- .NET - how to make a class such that only one othe
- is Object.getPrototypeOf() same as Object.construc
- Issue creating ImmutableMap with Class<?> as
- F# Object Initialization with a Constructor
I usually stick to factory methods, where I put the "constructors" for related classes in the same module (.BAS extension). Sadly, this is far from optimal since you can't really limit access to the normal object creation in VB6 - you just have to make a point of only creating your objects through the factory.
What makes it worse is having to jump between the actual object and your factory method, since organization in the IDE itself is cumbersome at best.
How about using the available class initializer? This behaves like a parameterless constructor:
I use a mix of factory functions (in parent classes) that then create an instance of the object and call a Friend
Init()
method.Class
CObjects
:Class
CObject
:I know the
Friend
scope won't have any effect in the project, but it acts as a warning that this is for internal use only. If these objects are exposed via COM then theInit
method can't be called, and setting the class toPublicNotCreatable
stops it being created.