Passing class pointer as argument to subscribe
I have a Base, Derived class structure and want to pass in the pointer to the base class as an argument. Shouldn't passing the pointer to the base class be the same as the memory address?
Base* base = new Derived1();
ros::Subscriber sub = nh.subscribe(topic, 100, &Base::callback, base);
I thought it should work but I get the following error:
error: no matching function for call to ‘ros::NodeHandle::subscribe(std::__cxx11::string&, int, Eigen::Matrix4d (Base::)(const PointCloud2ConstPtr&), Base&)’ ros::Subscriber sub = nh.subscribe(topic, 100, &Base::callback, base);