double d;
if( cin >> d ){//if it isn't a number, cin will set an error flag and evaluate to false
cout << "it's a double " << d << '\n';
}else{
cin.clear();//you need to clear the error flag before you can do any input
string str;
getline(cin, str);
cout << "it's a string " << str << '\n';
}
You could also take the input as a string and cast it to a double. I know that doesn't literally accomplish what you asked, but it could be handy depending on the next step you want to take with it. Just another option I thought was worth presenting.