in reply to Re: Re: single instance shared with module
in thread single instance shared with module

Sounds like you might want to pull the WriteLog stuff out into a third class, C. Give the first two classes, A and B, a has-a relationship to the new class C. If there's not too much overhead then A and B can maintain their own instances of C. If there's lots of overhead, then A and B can share a single instance of C by passing the instance reference to the constructors for A and B. Or you can make C a singleton class such that repeated calls to it's constructor yield the same object.

Matt

  • Comment on Re: Re: Re: single instance shared with module

Replies are listed 'Best First'.
Re: Re: Re: Re: single instance shared with module
by Jaap (Curate) on Sep 16, 2002 at 20:55 UTC
    All A has is WriteLog. Why would i want to pull it out just to put it in C?

    And design patters sound great but really all i need is a way to pass the instance in main to B.

    I will try passing it when i cann B's new method.