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);
Asked by mgmike1023 on 2023-01-25 00:08:53 UTC
Answers
Okay turns out my callback function as a return type instead of void. That was it.
Asked by mgmike1023 on 2023-01-27 17:23:33 UTC
Comments