开发者

a counter in constructor [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answer开发者_StackOverflow中文版ed in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 11 years ago.

how to put a counter in constructor??


if you want to count the number of created objects, you can use a static (class) variable

class CountingClass {
private:
  static int count;
public:
  CountingClass() {
    ++CountingClass::count;
  }
};
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜