samedi 30 mai 2015

why cant i initialize 3 default parameters at a time in c++

class Complex 
{
private:

float rp, ip;
//const int a=10;
//static int b;
//static const int c = 50;
public:
Complex();
//Complex(float );
/*Complex(float,float);*/
Complex(float , float = 20, float = 30);
} 

The above code works fine but when i try to have 3 default parameters

class Complex
{
private:
float rp, ip;
//const int a=10;//static int b;//static const int c = 50;
public:
Complex();
//Complex(float );
/*Complex(float,float);*/
Complex(float =10  , float = 20, float = 30);
} 

i get the below error main.cpp(12): error C2668: 'Complex::Complex' : ambiguous call to overloaded function complex.h(15): could be 'Complex::Complex(float,float,float)' complex.h(12): or 'Complex::Complex(void)'

Aucun commentaire:

Enregistrer un commentaire