Search
 
SCRIPT & CODE EXAMPLE
 

CPP

return by reference in cpp

int &returnValue(int& x){
	cout<<"x="<<x<<"The address of x is "<<&x<<endl;
	return x;
}
int main(){
	int a=20;
	int &b=returnValue(a);
	cout<<"a="<<a<<"The address of a is "<<&a<<endl;
	cout<<"b="<<b<<"The address of b is "<<&b<<endl;
	returnValue(a)=13;
	cout<<"a="<<a<<"The address of a is "<<&a<<endl;
    return 0;
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: c++ print vector without loop 
Cpp :: c++ loop through string 
Cpp :: round double to n decimal places c++ 
Cpp :: unordered_map header file c++ 
Cpp :: parallelize for loop c++ 
Cpp :: difference between lower and upper bound 
Cpp :: c++ char to uppercase 
Cpp :: cpp case 
Cpp :: lerp function c++ 
Cpp :: reverse c++ 
Cpp :: c++ constructors 
Cpp :: copy a part of a vector in another in c++ 
Cpp :: slice std::array cpp 
Cpp :: getline cpp 
Cpp :: Write C++ program to sort an array in ascending order 
Cpp :: how to create a min priority queue of pair of int, int 
Cpp :: c++ segmented sieve 
Cpp :: prime factorisation of a number in c++ 
Cpp :: why we use iostream in C++ programming 
Cpp :: cpp cin 
Cpp :: hamming distance c++ 
Cpp :: migration meaning 
Cpp :: declare nullptr c++ 
Cpp :: fast way to check if a number is prime C++ 
Cpp :: sort vector struct c++ 
Cpp :: how to sort vector of struct in c++ 
Cpp :: insert a character into a string c++ 
Cpp :: lua table contains 
Cpp :: integer to char c++ 
Cpp :: find in vector 
ADD CONTENT
Topic
Content
Source link
Name
8+9 =