ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

What are the C++ namespaces ros:: and std:: ? [closed]

asked 2012-08-19 03:23:40 -0500

SHPOWER gravatar image

updated 2014-01-28 17:13:22 -0500

ngrennan gravatar image

Hi,

I went through the tutorials and in the tutorial on how to write a subscriber (C++) I saw a line "ros::init(...)" and "std::stringstream ss;"

Sombody knows what are ros and std? where is their location/source?

please help me,

thanks in advance.

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by allenh1
close date 2015-06-25 12:19:18.956908

1 Answer

Sort by » oldest newest most voted
7

answered 2012-08-19 06:39:46 -0500

allenh1 gravatar image

Ros and std are C++ namespaces. These namespaces are comprised of many different files.

std: The standard C++ library. When programers use this line:

using namespace std;

They are stating that they are using the standard namespace (allows you to use the variables without putting std:: in front of them).

For example:

std::cout<<"Hello world!";

becomes:

cout<<"Hello world!";

When mixing namespaces, it is of bad practice to do the following:

using namespace std; 
using namespace ros;

Reason being, you may overload some methods you don't intend to. You can read more about this here.

edit flag offensive delete link more

Comments

thanks,that‘s all my wanted!!

sunsea_x gravatar image sunsea_x  ( 2014-11-26 23:37:27 -0500 )edit

Question Tools

Stats

Asked: 2012-08-19 03:23:40 -0500

Seen: 2,099 times

Last updated: Aug 19 '12