Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

pimpl c++

// --------------------
// interface (widget.h)
class widget
{
    // public members
private:
    struct impl; // forward declaration of the implementation class
    // One implementation example: see below for other design options and trade-offs
    std::experimental::propagate_const< // const-forwarding pointer wrapper
        std::unique_ptr<                // unique-ownership opaque pointer
            impl>> pImpl;               // to the forward-declared implementation class
};
 
// ---------------------------
// implementation (widget.cpp)
struct widget::impl
{
    // implementation details
};
Source by en.cppreference.com #
 
PREVIOUS NEXT
Tagged: #pimpl
ADD COMMENT
Topic
Name
4+4 =