I have the following 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();
};
I'm trying to disable default C++ constructor to implement my own (I intend to use it for copy). So, I declared it as a default. But, when I'm trying to implement it:
Fraction::Fraction(const Fraction&){}
Compiler throws the following error 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 fix these errors.