Day24

  1. 9.5节提到判断方法(predicate function)的概念,简单来说就是许多容器类别: 如link list, queue, stack都有一个方法isEnpty()或是isFull()就是所谓的判断方法。

  2. 蚂蚁书有个小优点就是美的段落的有个tips,这里提到从安全性考量传值呼叫的方式传递物件非常好,因为被呼叫的函式没法修改原来的物件,但是大型物件的副本记忆体用量大效率差,所以用指标或参照的方式效率比较好,而传const指标/参照可以结合两者的优点。做法是用指向const资料的指标当参数传入函式

  • Pointer to const object
    You can modify the pointer but you can't modify the object:
const Object* object_ptr = object1;
object_ptr = object2;                // Modify pointer, OK
object_ptr->x = 40;                  // Modify object, ERROR
  • Const pointer to object
    You can't modify the pointer but you can modify the object:
const Object* object_ptr = object1;
object_ptr = object2;                // Modify pointer, OK
object_ptr->x = 40;                  // Modify object, ERROR

ref :Constant pointers vs. pointer to constants in C and C++


<<:  食谱系统制作_下

>>:  D22/ 怎麽在 Compose 中用 Material Theme? - Theme

Days11

奇书共赏第十天,可惜蚂蚁书已经不再更新不然许多地方讲得很不错,但现在已经不是1980年而是2020年...

Day06-Scope && Hoisting

前言 在程序语言中了解程序的周期是很重要的。 在昨日我们已经先了解variables的一些规则了,其...

Day06 X 图片最佳化

给你五秒钟思考一下,你在日常生活中还有在使用没有任何图片,包括小小 的 Icon 也没有的网站吗?...

30天学会Python: Day 26-一心多用

同步执行 目前写的程序都是一行接着一行一行执行,这种执行的方式叫做 同步执行 print("...

ASP.NET MVC 从入门到放弃 (Day5) -C# 判断式 回圈介绍

接着来讲讲常用的判断式写法.... 简单来说以下就是玩攻略游戏 在选择选项的逻辑.... 单项if写...