Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


We're also offering banner ads on our site from just $5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


#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