I'm new to C++ and trying to understand variable naming better. If I declare two variables with the same name but different types in the same scope, like this:
```cpp
int a = 1;
char a = 'b';
```
I know I'd face an issue when trying to print their values, for example, using `std::cout << a;`. Is there a way to specify which variable type I'm referring to, or is this just not allowed?
1 Answer
You can't declare two variables with the same name in the same scope. If you try, the compiler will throw an error when you define `char a` after `int a`. All variable names must be unique in their respective scope.
So, variables can only have one type in a specific scope, right?