Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.

Tip of the Day
Language: C++
Expertise: Beginner
Oct 24, 2000



Application Security Testing: An Integral Part of DevOps

Significance of const Return

What is the significance of const return type from a function? Similar to:

 const int func1();

The const in this position guarantees that the caller of the function doesn't change the returned value. Note that the use of const in a function's return value is more useful when the function returns a reference or a pointer to, say an object's data member. It's less useful when return-by-value is used (as in your example) because the caller gets a local copy of the variable. Therefore, there's not much point in limiting the use of the caller's own copy.

DevX Pro
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date