I have a class which creates different kinds of variables.
And through some macro defines we want to initialize those variables.
#define NUMBER(number) JsonVariable(number)
#define STRING(text) JsonVariable(text)
#define TRUE JsonVariable(true)
#define FALSE JsonVariable(false)
Numbers are initialized fine, but Strings call the Bool constructor for unknown reasons.
JsonVariable(string x)
: type(String), s(x)
{
cout << "String" << x << endl;
sleep
}
JsonVariable(bool x)
: type(Boolean), b(x)
{
cout << "Boolean" << x << endl;
sleep
}
If I comment out the Bool constructor then the String one is called.
Any suggestions?
EDIT: This is a string constructor with the defined macros. std::string is used in the constructor.
JSON(test) = STRING("Hello")
Type is a defined enum. Also macros must be used as part of this assignment.
EDIT2: For clarification. Here's the enum type.
std::string is used with namespace std and thus single string. Also String is from the enum type so
String != string
typedef enum {
Null, Integer, Double, Boolean, String, Object, Array
} datatype;