小编skp*_*o19的帖子

比较 (struct &a, struct &b) 与 (const struct &a, const struct &b) 的 == 运算符

Point在头文件中定义了一个结构类,如下所示 -

namespace global_planner {
    class GlobalPlanner : public nav_core::BaseGlobalPlanner {
        struct Point {
            __uint32_t x, y; 
            bool operator==(const Point &p1 ) {
                return ((p1.x == x) && (p1.y == y));  
            }
            bool operator<(const Point &p1 ) const {
                return ((p1.x < x) || (p1.x == x && p1.y < y) ) ; 
            }   
        };
    public:
        ///
    private: 
        ////               
    };
    
};
Run Code Online (Sandbox Code Playgroud)

在我的源文件(名为global_planner.cpp)中,我有一个名为的函数,generate_straight_path定义如下 -

bool GlobalPlanner::generate_straight_path(const Point &p1, const Point &p2){        
    if(costmap_ros_->getCost(p1.x, p1.y) == costmap_2d::LETHAL_OBSTACLE) …
Run Code Online (Sandbox Code Playgroud)

c++ struct constants comparator

0
推荐指数
1
解决办法
39
查看次数

标签 统计

c++ ×1

comparator ×1

constants ×1

struct ×1