Ask Your Question
0

Can I have a sensor_msgs::Image::ConstPtr as data member?

asked 2013-02-11 03:40:55 -0500

kabamaru gravatar image

updated 2013-02-11 05:05:55 -0500

dornhege gravatar image

I have a class that gets an sensor_msgs::Image::ConstPtr and there are a lot of member functions acting to this same image. void extractData(const sensor_msgs::Image::ConstPtr &image)

I was wondering if it is possible to have a data member instead of sending the pointer from one function to the other.

I've tried adding: sensor_msgs::Image::ConstPtr ℑ

But it says uninitialized reference member. Tried also removing Const or Ptr in declaration with no success. Any ideas?

edit retag flag offensive close merge delete

Comments

FYI: For some reason the text appears to me as "sensor_msgs::Image::ConstPtr ℑ", when the OP actually entered "sensor_msgs::Image::ConstPtr &image"

Ivan Dryanovski gravatar image Ivan Dryanovski  ( 2013-02-11 03:54:00 -0500 )edit

Seems fixed now.

dornhege gravatar image dornhege  ( 2013-02-11 05:06:35 -0500 )edit

1 Answer

Sort by » oldest newest most voted
1

answered 2013-02-11 03:44:26 -0500

dornhege gravatar image

Yes, you can.

However, you cannot have it as a reference, i.e. remove the & in the declaration.

edit flag offensive delete link more

Comments

I don't want new objects. I want a reference or else it doesn't worth the loss in speed. I will go with passing around the smart pointer. Thanks anyway.

kabamaru gravatar image kabamaru  ( 2013-02-11 04:02:17 -0500 )edit
1

That's exactly what the smart pointer is intended for.

dornhege gravatar image dornhege  ( 2013-02-11 05:04:46 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2013-02-11 03:40:55 -0500

Seen: 1,249 times

Last updated: Feb 11 '13