阅读背景:

防止对象的多个实例

来源:互联网 

I have a superclass which instantiates my Sql class so all derived classes will be able to perform queries without instantiating their own Sql instances once they are constructed. This works good but I have a question I'm confusing myself about. One of the derived classes instantiates another derived class in its constructor so now, I believe I have 2 instances of the Sql class open because each instantiates the parent. I cannot override the parent class in any of the derived classes because they all need access to a a database instance to perform their own queries. Is there a way to prevent the derived class from calling the parent constructor when another derived class instantiates it?I have a superclass which instantiates my Sql c




你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: