Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Extra qualification C++

Tags:

c++

class

my compiler is telling me that I have an extra qualification error on one of my member functions, but I'm not sure why.

class DigitalTime {
 public:
  void DigitalTime::intervalSince(const DigitalTime& prev, int interval) const;
};

void DigitalTime::intervalSince(const DigitalTime& prev, int interval) const {
  return;
}

When I compile it, it says that my function intervalSince is extra qualified. I hope you guys can help me fix this issue

main.cpp:3:21: error: extra qualification on member 'intervalSince'
  void DigitalTime::intervalSince(const DigitalTime& aPreviousTime,
       ~~~~~~~~~~~~~^
1 error generated.
like image 719
swittuth Avatar asked Oct 24 '25 05:10

swittuth


1 Answers

When defining functions and variables inside the class definition, don't prefix them with the class name:

class DigitalTime {
public:
    void DigitalTime::intervalSince(const DigitalTime& previous, int interval);
};

Should be:

class DigitalTime {
public:
    void intervalSince(const DigitalTime& previous, int interval);
};
like image 200
Bill Lynch Avatar answered Oct 26 '25 17:10

Bill Lynch



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!