你如何处理VB6中缺少构造函数? [英] How have you dealt with the lack of constructors in VB6?

查看:466
本文介绍了你如何处理VB6中缺少构造函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

VB6类模块没有参数化构造函数。你选择了什么解决方案?使用facory方法似乎是一个明显的选择,但是让我吃惊!

VB6 class modules have no parameterized constructors. What solution have you chosen for this? Using facory methods seems like the obvious choice, but surprise me!

推荐答案

我通常坚持工厂方法,构造函数用于相同模块中的相关类(.BAS扩展)。可悲的是,这远远不是最优的,因为你不能真正限制访问在VB6中的正常对象创建 - 你只需要提出一点,只有通过工厂创建你的对象。更糟糕的是,不得不在实际对象和你的工厂方法之间跳转,因为IDE中的组织本身是最麻烦的。

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.

这篇关于你如何处理VB6中缺少构造函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆