闪亮的马路 发表于 2020-10-16 14:59:15

关于C++类的继承与重写

像下面MoveGroupInterface继承了MoveGroupInterfaceImpl,但是public中对MoveGroupInterfaceImpl的操作是什么意思?我理解的重写不是应该是方法吗,整个类也可以这样操作吗?

class MoveGroupInterface::MoveGroupInterfaceImpl
{
public:
MoveGroupInterfaceImpl(const Options& opt, const std::shared_ptr<tf2_ros::Buffer>& tf_buffer,
                         const ros::WallDuration& wait_for_servers)
    : opt_(opt), node_handle_(opt.node_handle_), tf_buffer_(tf_buffer)
{
   

    joint_model_group_ = getRobotModel()->getJointModelGroup(opt.group_name_);

    joint_state_target_.reset(new moveit::core::RobotState(getRobotModel()));
    joint_state_target_->setToDefaultValues();
    active_target_ = JOINT;
    can_look_ = false;
    can_replan_ = false;
    replan_delay_ = 2.0;
    goal_joint_tolerance_ = 1e-4;
    goal_position_tolerance_ = 1e-4;   // 0.1 mm
    goal_orientation_tolerance_ = 1e-3;// ~0.1 deg
    allowed_planning_time_ = 5.0;
    num_planning_attempts_ = 1;
    node_handle_.param<double>("robot_description_planning/joint_limits/default_velocity_scaling_factor",
                               max_velocity_scaling_factor_, 0.1);
    node_handle_.param<double>("robot_description_planning/joint_limits/default_acceleration_scaling_factor",
                               max_acceleration_scaling_factor_, 0.1);
    initializing_constraints_ = false;

    if (joint_model_group_->isChain())
      end_effector_link_ = joint_model_group_->getLinkModelNames().back();
    pose_reference_frame_ = getRobotModel()->getModelFrame();

    trajectory_event_publisher_ = node_handle_.advertise<std_msgs::String>(
      trajectory_execution_manager::TrajectoryExecutionManager::EXECUTION_EVENT_TOPIC, 1, false);
    attached_object_publisher_ = node_handle_.advertise<moveit_msgs::AttachedCollisionObject>(
      planning_scene_monitor::PlanningSceneMonitor::DEFAULT_ATTACHED_COLLISION_OBJECT_TOPIC, 1, false);

    current_state_monitor_ = getSharedStateMonitor(robot_model_, tf_buffer_, node_handle_);

    ROS_INFO_STREAM_NAMED(LOGNAME, "Ready to take commands for planning group " << opt.group_name_ << ".");
}

xieglt 发表于 2020-10-16 15:16:04

单冒号表示继承

class b
{
}
class a : public b
{
}


双冒号表示作用域,表示 class b 是 class a 的内部类

class a
{
public:
        a(){}
        ~a(){}
public:
        class b;
private:
        int m_a;
};

class a::b
{
public:
        b(){};
        ~b(){};
private:
       
};
页: [1]
查看完整版本: 关于C++类的继承与重写