How to make a function with optional parameters?

I would like to define the function
void OpenDoor(float DeltaTime,float TargetYaw =90.f).
Then, I try to use it with
OpenDoor(DeltaTime,0)
and
OpenDoor(DeltaTime).

However, the second way cannot be compiled.

The default argument should appear on the function declaration only. e.g.

class Example
{
    void Func(int32 A, int32 B = 10);
    void Foo();
};

void Example::Func(int32 A, int32 B)
{

}
void Example::Foo()
{
    Func(20);
}

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms