Open namrog84 opened 2 years ago
In the official UE they say don't have shadowed variables but don't offer reasonable suggested change. e.g. https://docs.unrealengine.com/5.0/en-US/epic-cplusplus-coding-standardblueprint-debugging-in-unreal-engine/
Shadowed variables are not allowed. C++ allows variables to be shadowed from an outer scope, but this makes usage ambiguous to a reader. For example, there are three usable Count variables in this member function:
class FSomeClass {
public:
void Func(const int32 Count) {
for (int32 Count = 0; Count != 10; ++Count) {
// Use Count
}
}
private:
int32 Count;
}
This is an arbitrary example but let's say I have a funciton
Traditionally in previous teams I've always named the member variable as m_target in this case but I know that's not recommended. I have seen some instances of Epic using
My
as a prefix but that sometimes doesn't look right either.I could rename the function parameter to be (AActor* InTarget)
Then what about if I need a local function variable do I name that localTarget?
I've yet to find consistent unreal specific guidelines for dealing with these 3 scopes since I thought I read that using
this->
isn't typically recommended?