I have a class:
class Fraction {
private:
int x;
int y;
public:
// Constructors
Fraction(long x = 0, long y = 1);
Fraction(const Fraction&)=default;//here is the problem
virtual ~Fraction();
};
And I'm trying to disable default C++ constructor for copy, to do my own. So, I declared it as a default. But, when I'm trying to implement it:
Fraction::Fraction(const Fraction&){}
Compiler throws some errors at me.
./src/Fraction.cpp:16:1: error: definition of explicitly-defaulted ‘Fraction::Fraction(const Fraction&)’ Fraction::Fraction(const Fraction&){ ^ In file included from ../src/Fraction.cpp:8:0: ../src/Fraction.h:22:2: error: ‘Fraction::Fraction(const Fraction&)’ explicitly defaulted here Fraction(const Fraction&)=default;
Is there any way to fix it? What I'm doing wrong, I found some articles about defaults, but nothing that can help me to fix these errors.
Aucun commentaire:
Enregistrer un commentaire