Skip to main content
added 6 characters in body
Source Link

Other way to emulate static constructor behaviour is to use instance variable with private constructor and static factory method.

Cat* Cat::give_birth() {
  static Cat *myone = 0;NULL;
  if (myone == 0NULL) {
    myone = new Cat();
  }
  return myone;
}

Other way to emulate static constructor behaviour is to use instance variable with private constructor and static factory method.

Cat* Cat::give_birth() {
  static Cat *myone = 0;
  if (myone == 0) {
    myone = new Cat();
  }
  return myone;
}

Other way to emulate static constructor behaviour is to use instance variable with private constructor and static factory method.

Cat* Cat::give_birth() {
  static Cat *myone = NULL;
  if (myone == NULL) {
    myone = new Cat();
  }
  return myone;
}
Source Link

Other way to emulate static constructor behaviour is to use instance variable with private constructor and static factory method.

Cat* Cat::give_birth() {
  static Cat *myone = 0;
  if (myone == 0) {
    myone = new Cat();
  }
  return myone;
}