编译问题

Abd*_*SSI 0 c++

有没有办法让这个编译?

并使它使用具有整数默认值的fct?

使用g ++.

#include <stdio.h>

int     fct(int a = 0)
{
        printf("a: %d\n", a);
        return (0);
}

void    fct()
{
}



int     main(void)
{

        fct();
        return (0);
}
Run Code Online (Sandbox Code Playgroud)

dbr*_*nk0 6

不,因为一旦你向fct(int)编译器添加默认值就无法猜出你要调用哪一个:

  • fct(int) 默认值为arg
  • fct()

您可以做的是删除默认值,并完全调用fct(0)或删除没有参数的值.