You need to make the getreq function const by adding the keyword const after the parameter list parentheses, e.g.That tells the compiler that the function won't change the state of the object, which is what the compiler needs to know before it allows you to call it from a const object (or a reference to a const object).Code:int getreq() const;