vendredi 9 octobre 2020

I've noticed I have a problem with NOT passing arguments

I'm a self taught C++ programmer. I mainly learned off of UE4 and I still have a ways to go. I'm taking computer science in school and I'm in CSC 211 (thats the second phase I guess? if class numbers arent universal). I noticed though in class that my teachers, and other students often pass arguments a lot. By a lot, I mean A LOT. For instance, we had a lab that was to create a check after someone has input what they'd like to have inside of a restaurant. I eventually got stuck and looked it up. I saw a lot of things such as : void CreateMenu(Menu MenuArray[]) so I eventually followed the tutorial and I got everything right. But when I program I do a lot of things like this (code from my UE4)

void AFPSCharacter::ServerFire_Implementation()
{
if (Item && Item->bPickedUp) {
        if (GetLocalRole() == ROLE_Authority) {
            NetFire();
            UE_LOG(LogTemp, Warning, TEXT("Server Fire"));
        }
    }
}

I know this code can look A LOT nicer and I guess my questions are:

How do you know when to pass arguments?

Why would you pass arguments even if you aren't using the variable at that time?

What is the difference between void CreateMenu() and void CreateMenu(Menu MenuArray[]) if a variable of MenuArray[] already exists and you can just update it without passing arguments?

Aucun commentaire:

Enregistrer un commentaire