You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
301 B
31 lines
301 B
2 years ago
|
//6.2.3const形参和实参.cpp
|
||
|
#include <iostream>
|
||
|
|
||
|
using namespace std;
|
||
|
|
||
|
void fa(const int as);
|
||
|
void fb(int as);
|
||
|
|
||
|
int main(){
|
||
|
int x=1,y=2;
|
||
|
const int a=1,b=2;
|
||
|
|
||
|
fa(x);
|
||
|
fa(a);
|
||
|
|
||
|
fb(y);
|
||
|
fb(b);
|
||
|
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
void fa(const int as){
|
||
|
// 无法修改值
|
||
|
}
|
||
|
|
||
|
void fb(int as){
|
||
|
// 可修改值
|
||
|
as=12;
|
||
|
|
||
|
}
|