• Quatlicopatlix@feddit.org
    link
    fedilink
    arrow-up
    3
    ·
    8 days ago

    I mean the thing with overloading is that your functions should have some difference in the paraameters they take, if you make 3 functions that have the exact same parameters of course you will not be shure what the compiler does(alötho i dont think that it would compile? But i dont think that i have ever done that)

    If you have a foo(int x float y) and a foo( int x ) function and you call it with just a x as parameter you can be shure the compiler will call your second function. If the compiler for some reasson tried to use the first foo it would throw a error because it wants a int and a float and you just gave it one int.

    I am shure that

    Foo(){ static int x =0;
    X +=1; Printf(“%d”,); }

    Foo(); every time foo is called x increments so print will be 1,2,3,4… for every call of foo

    Printf(“%d”,x); <- wont work because x cant be acessed here, it is out of scope.