I've been thinking about a class for "var" as you might see in GML or Javascript:
eg:
How could such a class be written in C++?
What I am thinking of right now, is something like:
To use it, it would be something like:
eg:
- Code:
var number;
number = 0;
number = string(number) + " - Now a string";
How could such a class be written in C++?
What I am thinking of right now, is something like:
- Code:
class var {
public:
double d_value;
int type;
char* s_value;
void set(double tosetto_v)
{
type = 0;
d_value = tosetto_v;
}
void set(char* tosetto_v)
{
type = 1;
s_value = tosetto_v; // I don't think this works, but im just showing my idea rather than making working code
}
}
To use it, it would be something like:
- Code:
int main()
{
var test;
test.set("Hello!");
system("cls");
if(test.type == 1)
{
cout << test.s_value << "\n";
}
system("pause");
return 0;
}