从缺陷中学习C++
0.前言 之前我的博客中还写道,有一本C++踩坑经验的书就好了,站在前人的肩膀上更有效率的coding,还真被我遇到了 本来在读这本书的时候,没想写笔记,但是有时遇到挺有意思的问题时,就忍不住想记录下 1.基础问题 由于基础知识不清楚导致的问题 1.1 宏展开问题 #define SQR(x) ((x) * (x)) i = 3; SQR(++i); 我们本意是要得到4*4...
0.前言 之前我的博客中还写道,有一本C++踩坑经验的书就好了,站在前人的肩膀上更有效率的coding,还真被我遇到了 本来在读这本书的时候,没想写笔记,但是有时遇到挺有意思的问题时,就忍不住想记录下 1.基础问题 由于基础知识不清楚导致的问题 1.1 宏展开问题 #define SQR(x) ((x) * (x)) i = 3; SQR(++i); 我们本意是要得到4*4...
这是2024年的第一篇博客,总结过去的一年,展望未来,留有期待 回顾2023 1.社区 华为云享专家 阿里专家博主 拿到三次华为的积极博主(华为社区每月TOP2-31) 以上写博客给我的反馈感很强,收到华为和阿里寄过来的各种礼物很不错 在此期间,还收到了清华大学出版社的邀请,但自认为水平不足,所以暂时婉拒 2.书籍 ...
我们将使用两种方法来实现这个功能:一种是当鼠标点击时,无论是否点击到模型,都会切换模型的轮廓显示;另一种是只有当鼠标点击到模型时,才会切换模型的轮廓显示。 方法一:鼠标点击切换轮廓显示 首先,我们来看第一种方法。以下是完整的代码: #include <osgViewer/Viewer> #include <osgDB/ReadFile> #include <...
1.动画沿着直线走 #include <osg/AnimationPath> #include <osg/MatrixTransform> #include <osgDB/ReadFile> #include <osgViewer/Viewer> int main() { osg::AnimationPath* path = new...
1.源码 #include <osgViewer/Viewer> #include <osg/Geode> #include <osg/ShapeDrawable> #include <osg/Texture2D> #include <osgDB/ReadFile> #include <osg/Light> #incl...
1.源码 #include <osgViewer/Viewer> #include <osg/Geode> #include <osg/ShapeDrawable> #include <osg/Texture2D> #include <osgDB/ReadFile> int main() { // 创建一个Viewer对象 ...
1.源码 #include <osgViewer/Viewer> #include <osg/Geode> #include <osg/ShapeDrawable> int main() { // 创建一个Viewer对象 osgViewer::Viewer viewer; // 创建一个用于绘制形状的Geode节点 osg::ref_ptr...
1.源码 #include <osgViewer/Viewer> #include <osg/Geode> #include <osg/ShapeDrawable> int main() { // 创建一个Viewer对象,这是OSG的主要接口 osgViewer::Viewer viewer; // 创建一个用于绘制形状的Geode节点 o...
1.起因 同事上班问了我一个问题,说在项目代码里看到了static struct的用法,但是编译器报错了,问我知道不知道,我脑子一呆,貌似没见过这种用法啊兄弟,只见过static一个变量或者函数的,static struct是什么操作呢 并且同事又说在网上查到,struct是不占空间的,static是占空间的,所以不能static struct,我寻思struct记忆中不是只占最大变量的...
1.vector 1.1 元素访问 只有at检查范围,如果索引越界,会抛出out_of_range,剩下三个会引发不明确的错误 c[idx] c.at[idx] c.front() c.back() 对一个空的vector调用operator[],front(),back()都会引发不明确的错误 std::vector v; v[5] = 1; // unde...