static data member

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Steve

    #1

    static data member

    I am experiencing the following:
    I am using a static member variable of a class to track how many instances
    of a class are in existence using MSVC 6 SP5. Access error occurs when I
    try to run. I try to debug, but anytime that a function in this class is
    called it vectors to an address in another loaded module. Say, I try to set
    a breakpoint on the statement in the constructor. As soon as the debugger
    tries to jump to the constructor, it instead jumps into an unknown spot in
    another loaded variable. Compiler or debugger problem maybe? Any guesses or
    workarounds? Thanks. Steve

    SomeClass.h:

    class SomeClass
    {
    private:
    static USHORT m_ushCount;
    };

    And define \ initialize \ use it at file scope like this:

    SomeClass.cpp:

    USHORT SomeClass::m_us hCount = 0;

    SomeClass::Some Class()
    {
    m_ushCount++;
    }

    SomeClass::~Som eClass()
    {
    m_ushCount--;

    if(m_ushCount == 0)
    {
    //delete some support stuff when there are no more instances of this
    class
    }
    }







  • Bob Hairgrove

    #2
    Re: static data member

    On Mon, 13 Dec 2004 20:18:55 GMT, "Steve" <Steve@someplac e.com> wrote:
    [color=blue]
    >I am experiencing the following:
    >I am using a static member variable of a class to track how many instances
    >of a class are in existence using MSVC 6 SP5. Access error occurs when I
    >try to run. I try to debug, but anytime that a function in this class is
    >called it vectors to an address in another loaded module. Say, I try to set
    >a breakpoint on the statement in the constructor. As soon as the debugger
    >tries to jump to the constructor, it instead jumps into an unknown spot in
    >another loaded variable. Compiler or debugger problem maybe? Any guesses or
    >workarounds? Thanks. Steve[/color]

    It sounds like you have an old .lib file somewhere in your project
    which is out of synch with the declarations in the headers.

    --
    Bob Hairgrove
    NoSpamPlease@Ho me.com

    Comment

    Working...