简体   繁体   中英

difference b/w const int func(); and int func() const;

I know when we use

int func() const;

then we cannot modify anything in the function except for mutable variable. But when i used

const int func();

It is allowing me to modify any thing?

const int func();

is function that returns const int and

int func() const;

is const function, ie function that doesn't modify the state of object, upon which it has been called.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM