开发者

in C++, what do the underscore signs in the multi-inheritance classes mean?

开发者 https://www.devze.com 2023-04-02 04:07 出处:网络
here is the code: PiGenerator::PiGenerator(PP_Instance instance) : pp::Instance(instance), graphics_2d_context_(NULL),

here is the code:

PiGenerator::PiGenerator(PP_Instance instance)
: pp::Instance(instance),
  graphics_2d_context_(NULL),
  pixel_buffer_(NULL),
  flush_pending_(false),
  quit_(f开发者_开发百科alse),
  compute_pi_thread_(0),
  pi_(0.0) {
  pthread_mutex_init(&pixel_buffer_mutex_, NULL);
}

Or is this even multi-inheritance? Can someone enlighten me?


It's (probably) just a convention: often, private variables are declared with a tailing underscore, so that one can easily recognize them.


No, that isn't specific to multiple inheritance. That's just the naming convention the original programmer decided to make.


Those are actually fields of the class PiGenerator. They all constitute the initialization list, which provides values to the various fields of the class before the constructor is entered. In this example, pp::Instance is the only base class constructor involved, and the rest are field initializations.

0

精彩评论

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