I have seen a few questions on this error, but I don't have much experience with making a class in C++, so I don't actually understand what the answers mean. I should also point out that I didn't write this code.
I'm getting the error stated in the title, and I believe it's coming from this header file, but I have no idea what the error means and how to fix it.
Here is the file:
#ifndef _QUICKTIMER_H_
#define _QUICKTIMER_H_
#include <cstdlib>
#include <string>
#include <chrono>
class QuickTimer {
public:
QuickTimer(const std::string& prefix = "");
~QuickTimer();
private:
std::chrono::high_resolution_clock::time_point mStartTime;
const std::string mPrefix;
};
#endif
and the full errors:
error: expected unqualified-id before ‘const’
QuickTimer(const std::string& prefix) :
^
error: expected ‘)’ before ‘const’
error: declaration of ‘~QuickTimer’ as non-member
~QuickTimer()
^
If anyone could explain to me what it means and what's going on, I'd really appreciate it, thanks!
Class name prefix are probably missing in the definition of your constructor and destructor. You should have something like that in a cpp file :
QuickTimer::QuickTimer(const std::string& prefix)
{
}
QuickTimer::~QuickTimer()
{
}