Alright, so i had the bright idea of using namespaces and an if statement to change the outcome of variables, in PHP i imagine i could’ve used concatenation however c++ doesnt seem to have concatenation as far as i can see so far.
so is there a way to get this code to work?
namespace Blue
{
int seven = 7;
int eight = 8;
}
namespace Red
{
int seven = 1;
int eight = 2;
}
and here is the main cpp file
int choice;
cin >> choice;
if(choice == 1)
{
char A[] = "Blue";
}else if(choice == 2){
char A[] = "Red";
}
cout << A::seven << endl;
cout << A::eight << endl;
I don’t think there is a way to do this, and if there were, it’s probably a bad idea. You would normally accomplish this behavior in C++ using polymorphism, e.g.:
and then: