As far as I know, C++ does not provide such kind of functionality to interpolate functions call inside a string. All you can do implement your own logic to do that.
Like,
1) define all the valid methods like this,
string getKingName(){
return "Some name";
}
string otherMethods(){
return "other values";
}
2) One helper method for mapping of function call
string whomToCall(string methodName){
switch(methodName){
case "getKingName()":
return getKingName();
break;
case "otherMethods()":
return otherMethods();
break;
default:
return "No such method exist";
}
}
3) break the line in tokens(words), read one by one and check for following condition also if
token starts with any alphabetical character and ends with "()" substring
istringstream ss(line);
do {
string token;
ss >> token;
if(isMethod(token))
cout << whomToCall(token) << " ";
else
cout << token<< " ";
} while (ss);
4) isMethod() to check if token's value can be a valid method name
bool isMethod(string token){
int n= token.length();
return isalpha(token[0]) && token[n-2]=='(' && token[n-1] == ')' ;
}