跳到正文

个人记录

const运用

用户 808657约 1 分钟
原文
文章信息与版本

文章信息

收录
2025年12月12日
更新
2025年12月12日
篇幅
约 1 分钟

版本

  1. v2当前
  2. v1

const\text{const} 是个函数可以将一个变量锁死,不能改变

for example\text{for example}:

C++
#include <bits/stdc++.h>
using namespace std;
const n=10;
int main()
{
  n=20;
  cout<<n;
 	return 0;
}

输出的是 1010 而并非 2020。

原文