我对C++很新,所以这个问题听起来很愚蠢,但即使我搜索了一段时间,但找不到答案。我使用ROS环境,但我的问题应该是一个普通的C++问题,所以我决定在这里发布它。C++在构造函数中使用类成员时未定义的引用
我有两个码
1)
ros::Duration max_storage_time = ros::Duration().fromNSec(1ULL * 1000000000LL);
tf::TimeCache odometryCache(max_storage_time);
2)
tf::TimeCache odometryCache(ros::Duration max_storage_time = ros::Duration().fromNSec(1ULL * 1000000000LL));
第二个编译,而第一一个没有。对我来说,似乎是完全一样的。第一个代码错误是: 未定义参考tf::TimeCache::TimeCache(ros::Duration)
TF :: TimeCache的文档可在http://docs.ros.org/jade/api/tf/html/c++/classtf_1_1TimeCache.html#acca87a70aeb9c3573cdbfec26f6bfe23
发现可能有人请告诉我,我缺少的是什么?代码段和第一个为什么不能编译的区别在哪里?
在此先感谢!
当你在'ros :: Duration max_storage_time = ros :: Duration()。from NSec(1ULL * 1000000000LL)''时,你在构造函数调用中做了什么?你有没有复制'ros :: Duration max_storage_time ='部分? – NathanOliver
是的,我相信,第二个(只使用一行)的作品。 – YeahScience