Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
你比较机灵❤️
interview
提交
456ced1e
I
interview
项目概览
你比较机灵❤️
/
interview
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
I
interview
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
456ced1e
编写于
4月 14, 2021
作者:
辉哈
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
reference, constant in-class initializer
https://github.com/huihut/interview/issues/79
上级
191b3053
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
11 addition
and
11 deletion
+11
-11
README.md
README.md
+2
-2
README_en.md
README_en.md
+3
-3
docs/README.md
docs/README.md
+2
-2
docs/en.md
docs/en.md
+4
-4
未找到文件。
README.md
浏览文件 @
456ced1e
...
...
@@ -69,7 +69,7 @@
*
自身是常量的指针(常量指针,const pointer)
*
引用
*
指向常量的引用(reference to const)
*
没有 const reference,因为引用
本身就是 const pointer
*
没有 const reference,因为引用
只是对象的别名,引用不是对象,不能用 const 修饰
> (为了方便记忆可以想成)被 const 修饰(在 const 后面)的值不可改变,如下文使用例子中的 `p2`、`p3`
...
...
@@ -82,7 +82,7 @@ const 使用
class
A
{
private:
const
int
a
;
// 常对象成员,
只能在初始化列表赋值
const
int
a
;
// 常对象成员,
可以使用初始化列表或者类内初始化
public:
// 构造函数
...
...
README_en.md
浏览文件 @
456ced1e
...
...
@@ -71,9 +71,9 @@ English
*
Pointer
*
Pointer to const
*
A pointer to a constant itself (const pointer)
*
Quot
e
*
Referenc
e
*
Reference to const
*
There is no const reference because the reference i
tself is a const pointer
*
There is no const reference because the reference i
s an alias of an object, the reference is not an object
> (Think of it for convenience) The value modified by const (after const) cannot be changed, such as `p2`, `p3` in the usage example below
...
...
@@ -87,7 +87,7 @@ const use
class
A
{
private:
const
int
a
;
// constant object member, can
only be assigned in the initialization list
const
int
a
;
// constant object member, can
use initialization list or in-class initializer
public:
// Constructor
...
...
docs/README.md
浏览文件 @
456ced1e
...
...
@@ -62,7 +62,7 @@
*
自身是常量的指针(常量指针,const pointer)
*
引用
*
指向常量的引用(reference to const)
*
没有 const reference,因为引用
本身就是 const pointer
*
没有 const reference,因为引用
只是对象的别名,引用不是对象,不能用 const 修饰
> (为了方便记忆可以想成)被 const 修饰(在 const 后面)的值不可改变,如下文使用例子中的 `p2`、`p3`
...
...
@@ -75,7 +75,7 @@ const 使用
class
A
{
private:
const
int
a
;
// 常对象成员,
只能在初始化列表赋值
const
int
a
;
// 常对象成员,
可以使用初始化列表或者类内初始化
public:
// 构造函数
...
...
docs/en.md
浏览文件 @
456ced1e
...
...
@@ -64,9 +64,9 @@
*
Pointer
*
Pointer to const
*
A pointer to a constant itself (const pointer)
*
Quot
e
*
Referenc
e
*
Reference to const
*
There is no const reference because the reference i
tself is a const pointer
*
There is no const reference because the reference i
s an alias of an object, the reference is not an object
> (Think of it for convenience) The value modified by const (after const) cannot be changed, such as `p2`, `p3` in the usage example below
...
...
@@ -80,7 +80,7 @@ const use
class
A
{
private:
const
int
a
;
// constant object member, can
only be assigned in the initialization list
const
int
a
;
// constant object member, can
use initialization list or in-class initializer
public:
// Constructor
...
...
@@ -95,7 +95,7 @@ public:
void
function
()
{
// object
A
b
;
// ordinary object, can call all member functions
, update constant member variables
A
b
;
// ordinary object, can call all member functions
const
A
a
;
// constant object, can only call constant member functions
const
A
*
p
=
&
a
;
// pointer variable, point to a constant object
const
A
&
q
=
a
;
// reference to constant object
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录