Change this:
if (y == 1)
int gender = askGender();
To this:
int gender;
if (y == 1)
gender = askGender();
Or even better this:
int gender = 0; // default: 0
if (y == 1)
gender = askGender();
More Related Contents:
- What is an ‘undeclared identifier’ error and how do I fix it?
- Why does the expression 'a++ += b' give an error?
- computer science
- Resolve build errors due to circular dependency amongst classes
- Is it possible to print a variable’s type in standard C++?
- Most efficient way to compare a variable to multiple values?
- What is the difference between an int and a long in C++?
- Pointer vs. Reference
- c++ multiple definitions of a variable
- const vs constexpr on variables
- Why is this program erroneously rejected by three C++ compilers?
- if (cin >> x) – Why can you use that condition?
- Why do I see strange values when I print uninitialized variables?
- How do I concatenate multiple C++ strings on one line?
- c++ compile error: ISO C++ forbids comparison between pointer and integer
- Is it better in C++ to pass by value or pass by reference-to-const?
- What makes a static variable initialize only once?
- Where do I find the definition of size_t?
- Do class functions/variables have to be declared before being used?
- Initializing container of unique_ptrs from initializer list fails with GCC 4.7
- Defining a variable in the condition part of an if-statement?
- Why can’t I do polymorphism with normal variables?
- c++ warning: address of local variable
- “Symbol(s) not found for architecture x86_64” on QtCreator project
- C++ Global variable declaration
- error::make_unique is not a member of ‘std’
- error: Class has not been declared despite header inclusion, and the code compiling fine elsewhere
- is it possible to make function that will accept multiple data types for given argument?
- Can’t get visual studio C++ include file ‘excpt.h’ to get installed
- constexpr not working if the function is declared inside class scope