Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


#ActualMatt-D

Posted 23 June 2013 - 01:13 PM

Thanks.

Can you explain a bit more what you mean with making member functions const-correct?

I think it begins with the passed objects to the functions, which should or shouldn't be modified (and prevent copying variables when not needed).

 

Unless of course, the basics behind are not OK (structure of the classes, what's dependent on what, which member functions should be smaller/ split up etc.).

Not sure if this is the case 100%, but anyway this first step feels like good practice. Next could be to see if I can make it more efficient/ with smaller/ other member functions.

 

Or do you mean something else?

 

This should help:

http://en.wikipedia.org/wiki/Const-correctness

[C++ FAQ / Section 18] Const correctness: http://www.parashift.com/c++-faq/const-correctness.html
In particular:
- http://www.parashift.com/c++-faq/overview-const.html
- http://www.parashift.com/c++-faq/const-and-type-safety.html
GotW #6a: http://herbsutter.com/2013/05/24/gotw-6a-const-correctness-part-1-3/
GotW #6b: http://herbsutter.com/2013/05/28/gotw-6b-solution-const-correctness-part-2/
 


#1Matt-D

Posted 23 June 2013 - 01:12 PM

Thanks.

Can you explain a bit more what you mean with making member functions const-correct?

I think it begins with the passed objects to the functions, which should or shouldn't be modified (and prevent copying variables when not needed).

 

Unless of course, the basics behind are not OK (structure of the classes, what's dependent on what, which member functions should be smaller/ split up etc.).

Not sure if this is the case 100%, but anyway this first step feels like good practice. Next could be to see if I can make it more efficient/ with smaller/ other member functions.

 

Or do you mean something else?

 

This should help:

[C++ FAQ / Section 18] Const correctness: http://www.parashift.com/c++-faq/const-correctness.html
In particular:
- http://www.parashift.com/c++-faq/overview-const.html
- http://www.parashift.com/c++-faq/const-and-type-safety.html
GotW #6a: http://herbsutter.com/2013/05/24/gotw-6a-const-correctness-part-1-3/
GotW #6b: http://herbsutter.com/2013/05/28/gotw-6b-solution-const-correctness-part-2/
 


PARTNERS