Can I use C++ class members initialized in the initializer list, later in the list?

前端 未结 2 995
悲&欢浪女
悲&欢浪女 2021-01-12 13:06

I am rewriting some code to eliminate global variables and made a class constructor/destructor handle cleanup of some third party library resources, but I am concerned about

2条回答
  •  独厮守ぢ
    2021-01-12 13:31

    The members are initialized in the order they are declared, top to bottom

    PoDoFo::PdfOutputDevice device;
    PoDoFo::PdfStreamedDocument document;
    PoDoFo::PdfPainter painter;
    

    so it is safe to use device to initialize document.

提交回复
热议问题