Cherno c++ learning -- references

references has to reference a already existed variable.

1.references不占用memery

2.when you decleare a reference ,you have to immediately assign it to something

int& ref;  //error!!

3.once you declear a reference,you cannot change what it references!

#include<iostream>

#define LOG(x) std::cout<<x<<std::endl;

//pass that memery address to that function
void increment(int *value){
	(*value)++;
}

int main(int argc, char const *argv[])
{
	int a =5;
	//increment(&a);
	//LOG(a)
	int& ref = a; //& is part of the type-->int& 表示int类型的reference
	//ref is just an alias for a , not another variables!
	std::cin.get();
	return 0;
}

    int& ref = a; //& is part of the type-->int& 表示int类型的reference
    //ref is just an alias for a , not another variables!