Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Posts: 777
Registered: ‎07-21-2012
My Device: 9810
My Carrier: 0

Explain const meaning in blackberry cascasde



can you please tell me the what is meaning of const  blackberry cascade .they many time used like this


 QString email() const;  ?


QString firstName() const;


In function


QString AddressBook::filter() const
return m_filter;

Posts: 1,524
Registered: ‎12-18-2012
My Device: Z30, Z10 LE, DevAlpha C, PlayBook

Re: Explain const meaning in blackberry cascasde


This means that the function will not modify the members of the class and this allows the function to be called via constant pointer or reference to the class.

I strongly recommend reading a book on C++ as it will give answers to most of the questions of this type because these are basic C++ constructs and not directly related to Cascades library.

These questions can't be answered in a few sentences. Forum members are trying to help, but it won't give a complete understanding on how it works. And this is crucial for writing stable and well designed apps.

Andrey Fidrya, @zmeyc on twitter
Posts: 17,024
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Explain const meaning in blackberry cascasde

it means the returned value may not be altered.
you should maybe read some c++ tutorials to be more familiar with the basic concepts.
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Explain const meaning in blackberry cascasde


"it means the returned value may not be altered."

I think that is meaning if a const is at the beginning (on the return parameter), for example:

const QString email() const

Zmey's answer applies for trailing const.

And yes I agree - OP you should read a book or do a course on C++.