OK, I've seen this error explained at least 100 times on the net. But in every case, it seems to be an error of #including <string.h> instead of <string> or metioning string instead of std::string. But, I've done all those things. And it still does not work.
By way of background: I am a LONG time newbie C++ programmer (meaning that I write code in spurts and then not at all for several years, which means that whenever I advance beyond newbie status, I slide back after time). I have also traditionally been coding using the old Borland compiler (which works, even if it is ancient, but I like the IDE). I have now been trying to come into the 21st century by using gnu c++ (g++ and mingw). The code problem that I am presenting compiles using the Borland compiler, but gives me the error message only when I try to compile with g++.
The problem code:
#ifndef ERRORHANDLER_H
#define ERRORHANDLER_H
#define DOS
#include <string>
#include <time.h>
#include <fstream>
#include <dir.h>
#include <iostream>
#include <stdlib.h>
class ErrorReport
{
private:
std::string logfilename;
public:
void set (const std::string name) {logfilename=name;};
std::string file() const {return logfilename;};
std::string GetNow() const
{
std::string now;
char date [10];
_strdate(date);
char time [10];
_strtime(time);
now= date;
now+= " ";
now+= time;
now+= " ";
return now;
};
. . .
You can see I use std::string and have this header protected with an #ifndef envelope. I am not using namespace in the header, which people tell me is a bad thing to do.
So, any suggestions??
Thanks for your time.