If i need to return a referenced value, this function code works?
&int returnvalue(){
return &property;
}
I want to return just a reference to a property of my class, it’s possible to do?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can return references in C++. However, you need to get the syntax right:
In the function type declaration,
intcomes before the&. In thereturnstatement, you don’t want to take the address ofproperty, because that is a pointer.