随笔分类 - C++
摘要:1.创建功能包,参考ros官方方式Writing a simple publisher and subscriber (C++) — ROS 2 Documentation: Humble documentation ros2 pkg create --build-type ament_cmake
阅读全文
摘要:class Person { public: //this指针的本质 是指针常量 指针的指向是不可以修改的 // const Person * const this; //在成员函数后面加const 修饰的是this指向,让指针的指向的值也不可以修改 void showPerson() const
阅读全文
摘要:c++中的拷贝构造函数调用时机通常有三种情况 1.使用一个已经创建完毕的对象来初始化一个新的对象 2.值传递的方式给函数参数传值 3.以值方式返回局部对象 //情况1 class Person { public: Person(){ std::cout <<"无参数构造函数" << std::end
阅读全文
摘要:#include <iostream> //引用的含义:int &a 实际上是 int * const a 本质上就是一个指针常量 int& swap() { static int a = 10; return a; } int main() { int &ref = swap(); std::co
阅读全文
摘要:1.常量指针 --const修饰指针(const int * p) 特点:指针的指向可以修改,但是指针指向的值不可以修改 2.指针常量 --const修饰常量(int * const p) 特点:指针的指向不可以修改,但是指针指向的值可以修改 3. const及修饰指针又修饰常量 (const in
阅读全文