/
githubmirror
/
CPlusPlusThings
Обзор
Документация
Войти
/
githubmirror
/
CPlusPlusThings
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
practical_exercises/10_day_practice/day4/const/obj_ref.cpp
26 строк
404 B
zhangxing
support bazel complie this project and format code.
30 мар 2024, 17:00
30 мар 2024, 17:00
3c8a3f2
Код
Авторство
О чём код?
#include <iostream> using namespace std; void display(const double &r); class A { public: A(int i, int j) { x = i; y = j; } private: int x, y; }; int main() { double d(9.5); display(d); A const a(3, 4); // a是常对象,不能被更新 return 0; } void display(const double &r) //常引用做形参,在函数中不能更新 r所引用的对象。 { cout << r << endl; }