Hello everyone.
I just had a simple question involving variables.
I know how to declare integers using "int" and strings using "std::string".
There exist other data types such as "char", "long", etc.
I was wondering how I could assign multiple data types to one variable.
Here is an example of how this overloaded variable would help:
This is a simple program that would let the user know the integer or string they typed in.Code:#include <iostream> #include <string> using namespace std; int main() { multiple datatype variable "V" would be declared here cout << "Type in an integer or string: "; cin >> V; cout << endl; cout << "The number or letter you just typed was: "; cout << V; }