Re: Beginner coder
Building off of what Zageron mentioned, one super important thing you need to learn is how to name member variables differently from parameters and other temp variables. If you can't immediately tell if a variable is a member just by the name then you need to rethink your naming convention. I've run in to way too many problems due to poor naming conventions.
For example in your class sample:
Make it m_num or something similar to make it very obvious that it's a member and not just a local temp variable. That way if you have a function that takes in a number that you want to call num you won't be confused as hell trying to figure out which num is the member and which is the input parameter. For example, try to guess what happens in this situation:
Sure you could do this.num = num, but even that is kinda ugly. Do you really want to have to remember to prefix every member with "this."? If you forget then you'll completely screw yourself and have to hunt down a really hard to find bug.
Building off of what Zageron mentioned, one super important thing you need to learn is how to name member variables differently from parameters and other temp variables. If you can't immediately tell if a variable is a member just by the name then you need to rethink your naming convention. I've run in to way too many problems due to poor naming conventions.
For example in your class sample:
Code:
class int num;
Code:
class SomeClass
{
int num;
void SomeFunc(int num)
{
num = num;
}
};










Comment