97.3k views
19 votes
Can we use a data type as a condition in C++?

For example, if a user enters a number in a string input user prompt, it executes a certain set of instructions(code). Because when I enter a number instead of a character in the terminal, it skips all cin inputs and keeps printing cout until the end of the code.

User TunaMaxx
by
8.9k points

1 Answer

9 votes
No you can’t use a data type as a condition but you can use function overloading or templates to attempt to bypass this.
User Valera Maniuk
by
8.0k points

No related questions found

Welcome to QAmmunity.org, where you can ask questions and receive answers from other members of our community.