[Solved] How to pass private class member by constant reference? [closed]


Ok, maybe this will help you to start thinking in c++, even if you did not make clear explanation what you need, if I may guess, what you probably think of is that you want to be able to call print() member function on const instances of MyClass, or rvalue has been bound to const lvalue reference, so you need to mark print as const member function of type MyClass.

class MyClass
{
    public:
        void print() const; // prints X to console

    private:
        std::vector<int> X (4, 100);

};

solved How to pass private class member by constant reference? [closed]