fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. namespace std_msgs {
  5.  
  6. template <class T>
  7. struct ColorRGBA_ {
  8. typedef ColorRGBA_<T> Type;
  9.  
  10. ColorRGBA_(): r(0.0), g(0.0), b(0.0), a(0.0) { }
  11. //ColorRGBA_(const ContainerAllocator& _alloc) : r(0.0), g(0.0) , b(0.0), a(0.0) { }
  12.  
  13. typedef float _r_type;
  14. _r_type r;
  15. typedef float _g_type;
  16. _g_type g;
  17. typedef float _b_type;
  18. _b_type b;
  19. typedef float _a_type;
  20. _a_type a;
  21.  
  22. /*typedef boost::shared_ptr< ::std_msgs::ColorRGBA_<ContainerAllocator> > Ptr;
  23.   typedef boost::shared_ptr< ::std_msgs::ColorRGBA_<ContainerAllocator> const> ConstPtr;
  24.   boost::shared_ptr<std::map<std::string, std::string> > __connection_header;*/
  25.  
  26. };
  27.  
  28. typedef ColorRGBA_<float> ColorRGBA;
  29.  
  30. }
  31.  
  32. class A {
  33. public:
  34. static std_msgs::ColorRGBA white; // struct with 4 float members;
  35. };
  36.  
  37. // std_msgs::ColorRGBA A::white = {1,1,1,1}; // Just works for aggregates
  38.  
  39.  
  40. std_msgs::ColorRGBA initializeMe() {
  41. std_msgs::ColorRGBA obj;
  42. obj.r = 22.0f;
  43. // ..
  44. return obj;
  45. }
  46.  
  47. std_msgs::ColorRGBA A::white = initializeMe();
  48.  
  49. int main()
  50. {
  51. cout << A::white.r;
  52. }
Success #stdin #stdout 0s 3340KB
stdin
Standard input is empty
stdout
22