Pregunta

Constructors:

A()
{
    std::cout<<"In A const";
}

A(int a = 3)
{
    std::cout<<"In a with default :"<<a;
}

Creating objects:

A a;
A a1(4);

The above code is showing error: call of overloaded 'A()' is ambiguous

¿Fue útil?

Solución

You've given a default value to the second constructor:

A(int a = 3)

So this covers both instances of: A() and A(3), making the first definition redundant

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top