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
        void print() const; // prints X to console

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


Browse More Popular Posts

Leave a Comment