Home > Back-end >  Class object counter, why always have a problem!! O bosses!
Class object counter, why always have a problem!! O bosses!

Time:09-25


Me what's wrong with this counter is ah, why each time debugging output is zero,

CodePudding user response:

Define the num in main. CPP in, or to define num as Complex static members

CodePudding user response:

Num should be defined as static members of the class

CodePudding user response:

I see not too clear your code that may not be accurate,
Global static, class static, internal static function, can achieve class count,
Key I didn't see you as if the destructor, an object is produced, and then it died, then the class count the same?
And to accurately record the accumulative, want to consider structure, destructor, copy, assign, and so on a series of fuck do,,,,,,,,

CodePudding user response:

Post code, good let us help you debug it

CodePudding user response:

reference 3 floor truth is right or wrong response:
I see not too clear your code, say may not be accurate,
Global static, class static, internal static function, can achieve class count,
Key I didn't see you as if the destructor, an object is produced, and then it died, then the class count the same?
And to accurately record the accumulative, want to consider structure, destructor, copy, assign, and so on a series of fuck do,,,,,,,,

Because didn't require the destructor in the title, so I didn't write the
  • Related