Jump to content

  • Log In with Google      Sign In   
  • Create Account


#Actualjwezorek

Posted 06 February 2013 - 10:56 AM

Steps to writing const-correct code:
 
1. Understand what const variables and const references & pointers actually mean and how they behave at compile time. Read about it. Make a sample program and test what happens when you try to do various things.
 
2. Understand what a const member function is. As above...
 
3. In your actual code, when you write a new function or member function attempt to make all of its parameters const, especially pointers and refences. Deal with the syntactic fallout.
 
4. Where 3. turned out to be impossible realize that those parameters can't be const.
 
5. Do this for a while and it will all become second nature.

#2jwezorek

Posted 06 February 2013 - 10:55 AM

Steps to writing const-correct code:
 
1. Understand what const variables and const references & pointers actually mean and how they behave at compile time. Read about it. Make a sample program and test what happens when you try to do various things.
 
2. Understand what a const member function is. As above...
 
3. In your actual code, when you write a new function or member function attempt to make const *every* pointer or reference parameter that the function takes. Deal with the syntactic fallout.
 
4. Where 3. turned out to be impossible realize that those parameters can't be const.
 
5. Do this for a while and it will all become second nature.

#1jwezorek

Posted 06 February 2013 - 10:53 AM

Steps to writing const-correct code:
 
1. Understand what const variables and const references & pointers actually mean and how they behave. Read about it. Make a sample program and test what happens when you try to do various things.
 
2. Understand what a const member function is. As above...
 
3. In your actual code, when you write a new function or member function attempt to make const *every* pointer or reference parameter that the function takes. Deal with the syntactic fallout.
 
4. Where 3. turned out to be impossible realize that those parameters can't be const.
 
5. Do this for a while and it will all become second nature.

PARTNERS