Getting error “a nonstatic member reference must be relative to a specific object” while both member are in the same class
In C++ you can not access a non static class member from a static method. Make it a normal method and try like below:- Else declare pub as static member Also refer to the below answer C++ static member functions and variables