So I'm building a Regex class, with a simple constructor:
regex.hpp
#ifndef REGEX_CUSTOM_CLASS
#define REGEX_CUSTOM_CLASS
#include <stdio.h>
using namespace std;
class Regex
{
private:
/* data */
public:
char *regex;
Regex(char str[]);
};
#endif // REGEX_CUSTOM_CLASS
regex.cpp
#include <iostream>
#include <list>
#include <assert.h>
#include <ctype.h>
#include <stdio.h>
#include "regex.hpp"
using namespace std;
Regex::Regex(char str[])
{
regex = str;
}
tools.cpp
#include <iostream>
#include <stdio.h>
#include "lib/regex/regex.cpp"
using namespace std;
int main() {
Regex my_regex("//");
cout << my_regex.regex << endl;
return 0;
}
But after I compile it to .exe file and run it, I get this error message:
warning: ISO C++ forbids converting a string constant to 'char*' Regex my_regex("//");
I think the problem is with the data types. What is the problem?