Global instances inside class

Discussion in 'C++' started by Krice, Apr 5, 2008.

  1. Krice

    Krice Guest

    My Window class is using Tileset class to draw the window borders.
    Tileset is a global instance set up earlier:

    extern Tileset *window_borders;

    void Window::Show()
    {
    //some code...
    window_borders->Draw(x,y,tile);
    //etc...

    This is bad, isn't it? At least it makes Window class dependent of
    that
    global Tileset instance. The only alternative solution I can think of
    is
    passing a pointer to Tileset in Window constructor, but it seems funny
    to
    do that, because there is only one instance of Tileset for window
    borders.
    Is this problem at all or is there some other way to do this?
    Krice, Apr 5, 2008
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. John Wohlbier
    Replies:
    2
    Views:
    366
    Josiah Carlson
    Feb 22, 2004
  2. Replies:
    4
    Views:
    373
    Niklas Norrthon
    Dec 29, 2005
  3. Replies:
    8
    Views:
    459
    James Stroud
    Jan 29, 2009
  4. Phil

    Global Events that all instances of a control handles

    Phil, Sep 11, 2006, in forum: ASP .Net Building Controls
    Replies:
    1
    Views:
    137
  5. Phil

    Global Events that all instances of a control handles

    Phil, Sep 11, 2006, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    119
Loading...

Share This Page