References Trong C++

Tạo Tài Liệu Tham Khảo

Một biến tham chiếu là một “tham chiếu” đến một biến hiện có và nó được tạo bằng toán tử &:

string food = "Pizza";  // food variable
string &meal = food;    // reference to food

Bây giờ, chúng ta có thể sử dụng tên biến food hoặc tên meal bữa ăn để tham chiếu đến biếnfood:

Example

string food = "Pizza";
string &meal = food;

cout << food << "\n";  // Outputs Pizza
cout << meal << "\n";  // Outputs Pizza

 

 

The post References Trong C++ first appeared on Techacademy.

source https://techacademy.edu.vn/references-trong-c/

Leave a comment