Split a C++ class declaration

后端 未结 5 829
野的像风
野的像风 2021-01-06 01:46

I want to know if I can split a C++ class declaration

Original class

    class P
    {
        private: 
           int id;
           //some really          


        
5条回答
  •  耶瑟儿~
    2021-01-06 02:00

    Something like this?

    class P
    {
    private:
        class Impl
        {
        public:
           int id;
           //some really secret method
           int secretMethod();
        };
    
    private:
        Impl* _pimpl;
    
    protected:
        int x;
    
    public:
        P() : _pimpl(new P::Impl()) {}
        ~P() { delete _pimpl; } 
        int getX();
    
    };
    

提交回复
热议问题