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!


#ActualParadigm Shifter

Posted 21 June 2013 - 02:14 PM

You mean *p2 = p1 in example #2. They aren't members of the class so that is OK. EDIT: Why is it a member of the class though? It doesn't use the class at all. If you want it to be a member of the class make it static.

 

pAge is a reference not a pointer in example #3. So *pAge doesn't make any sense. You mean mAge = pAge. It can't be const though, correct, since it modifies mAge which is a member of the class.

 

You need the const in the definition too since you can provide a const and a non-const implementation of the same function (the const one will be called if called with a const variable).

 

I'd also rethink your naming conventions if you use p prefix for all function arguments. I'd use a p prefix for pointers. If you need a naming convention for parameters I'd use "a" for argument.


#1Paradigm Shifter

Posted 21 June 2013 - 02:11 PM

You mean *p2 = p1 in example #2. They aren't members of the class so that is OK.

 

pAge is a reference not a pointer in example #3. So *pAge doesn't make any sense. You mean mAge = pAge. It can't be const though, correct, since it modifies mAge which is a member of the class.

 

You need the const in the definition too since you can provide a const and a non-const implementation of the same function (the const one will be called if called with a const variable).

 

I'd also rethink your naming conventions if you use p prefix for all function arguments. I'd use a p prefix for pointers. If you need a naming convention for parameters I'd use "a" for argument.


PARTNERS