main.cpp
#include <bits/stdc++.h> using namespace std; #define SWITCH(x) string& _s=x;if(0) #define CASE(y) }else if(_s==y){ #define DEFAULT }else{ int main() { string prompt = "Your name?"; SWITCH(prompt) { CASE("Who are you?") cout << "Claude" << endl; CASE("No, really?") cout << "Chatgpt" << endl; DEFAULT cout << "Gemini" << endl; } }
Output