gpt4 book ai didi

c++ - C to C++ 转换杂项声明

转载 作者:搜寻专家 更新时间:2023-10-31 01:07:08 25 4
gpt4 key购买 nike

要转换的代码:

struct CurrentFrameCloudView
{
CurrentFrameCloudView() : cloud_device_ (480, 640), cloud_viewer_ ("Frame Cloud Viewer")
{
cloud_ptr_ = PointCloud<PointXYZ>::Ptr (new PointCloud<PointXYZ>);

cloud_viewer_.setBackgroundColor (0, 0, 0.15);
cloud_viewer_.setPointCloudRenderingProperties (visualization::PCL_VISUALIZER_POINT_SIZE, 1);
cloud_viewer_.addCoordinateSystem (1.0);
cloud_viewer_.initCameraParameters ();
cloud_viewer_.setPosition (0, 500);
cloud_viewer_.setSize (640, 480);
cloud_viewer_.setCameraClipDistances (0.01, 10.01);
}

void
show (const KinfuTracker& kinfu)
{
kinfu.getLastFrameCloud (cloud_device_);

int c;
cloud_device_.download (cloud_ptr_->points, c);
cloud_ptr_->width = cloud_device_.cols ();
cloud_ptr_->height = cloud_device_.rows ();
cloud_ptr_->is_dense = false;

cloud_viewer_.removeAllPointClouds ();
cloud_viewer_.addPointCloud<PointXYZ>(cloud_ptr_);
cloud_viewer_.spinOnce ();
}

void
setViewerPose (const Eigen::Affine3f& viewer_pose) {
::setViewerPose (cloud_viewer_, viewer_pose);
}

PointCloud<PointXYZ>::Ptr cloud_ptr_;
DeviceArray2D<PointXYZ> cloud_device_;
visualization::PCLVisualizer cloud_viewer_;
};

问题:

谁能给我解释一下这行代码?

void
setViewerPose (const Eigen::Affine3f& viewer_pose) {
::setViewerPose (cloud_viewer_, viewer_pose); // especially here ...
}

欢迎任何帮助!

最佳答案

::setViewerPose (cloud_viewer_, viewer_pose);

此行调用全局函数 setViewerPose()。双冒号 :: 确保它调用全局命名空间中的函数而不是当前类中的函数。

通常,:: 用于访问命名空间成员,如 std::cout,或静态类成员,如 MySingleton::instance。如果您在左侧省略命名空间/类名,那么它会访问全局项。

关于c++ - C to C++ 转换杂项声明,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19736037/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com