#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#define LOG(x) std::cout << #x":" << x << std::endl;
using namespace std;
void Increment_a(int value)
{
value++;
}
void Increment_b(int& value)
{
value++;
}
void Increment_c(int* value)
{
// 先進行逆向引用再增量運算
(*value)++;
}
void Increment_d(int* value)
{
// 先進行增量運算再進行逆向引用
*value++;
}
int main()
{
/*1.引用的用法*/
// int a=5;
// int& b=a;
// b = 10;
// LOG(a);
/*2.引用的強大功能*/
int a = 5;
int b = 5;
int c = 5;
int d = 5;
Increment_a(a);
Increment_b(b);
Increment_c(&c);
Increment_d(&d);
LOG(a);
LOG(b);
LOG(c);
LOG(d);
}
【引用】基本用法
最新推荐文章于 2023-04-01 15:36:50 发布