【C++|Bug】解决 error: default argument given for parameter x of xxx

【C++|Bug】解决 error: default argument given for parameter x of xxx,第1张

问题背景
Scanning dependencies of target test1
[ 10%] Building CXX object CMakeFiles/test1.dir/src/filter.cpp.o
/home/zth/Projects/PCReg/src/filter.cpp:19:6: error: default argument given for parameter 3 of ‘void voxel_filter(pcl::PointCloud<pcl::PointXYZ>::Ptr&, pcl::PointCloud<pcl::PointXYZ>::Ptr&, float)[-fpermissive]
   19 | void voxel_filter(pcl::PointCloud<PointT>::Ptr &cloud, pcl::PointCloud<PointT>::Ptr &cloud_filtered, float leaf_size = 1.0f) {
      |      ^~~~~~~~~~~~
In file included from /home/zth/Projects/PCReg/src/filter.cpp:8:
/home/zth/Projects/PCReg/include/filters.h:15:6: note: previous specification in ‘void voxel_filter(pcl::PointCloud<pcl::PointXYZ>::Ptr&, pcl::PointCloud<pcl::PointXYZ>::Ptr&, float)’ here
   15 | void voxel_filter(pcl::PointCloud<PointT>::Ptr &cloud, pcl::PointCloud<PointT>::Ptr &cloud_filtered, float leaf_size = 1.0f);
      |      ^~~~~~~~~~~~
make[2]: *** [CMakeFiles/test1.dir/build.make:102: CMakeFiles/test1.dir/src/filter.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:76: CMakeFiles/test1.dir/all] Error 2
make: *** [Makefile:84: all] Error 2
解决方法

C++ 在声明函数时不可以给形参默认值,在定义函数时可以给默认值。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/langs/3002087.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-09-27
下一篇 2022-09-27

发表评论

登录后才能评论

评论列表(0条)

保存