C++ 常量引用

    技术2025-12-17  17

    #include<iostream> #include<string> using namespace std; int main() { //常量引用 //使用场景:用来修饰形参,防止误操作 //int a = 10; //加上const之后编译器将代码修改int temp = 10; const int & ref = temp; const int & ref = 10;//引用必须引一块合法的内存空间 ref = 20; //加入const之后变为只读,不可以修改 system(" pause"); return 0; }

    Processed: 0.023, SQL: 10