+ 2
C++ calculator
I'm tryin to make a cpp calculator but idk how do I make the user to input a int instead of str. basiclly when someone inputs a string I want it to print ,,That isn't a number" How do I do that?
8 Respostas
+ 3
int input;
if (!(std::cin >> input))
std::cerr << "Your input could not be validated, did you provide something else than a number?\n";
+ 1
It's if you don't want to use the std namespace: https://youtu.be/4NYC-VU-svE
+ 1
Yes, it groups classes, functions and globals, mainly to avoid name conflicts between libraries.
+ 1
namespace example
{
class Something {…};
void foo(){…};
}
int main()
{
example::foo();
}
//or
using namespace example;
int main()
{
foo();
}
0
Oh but what does ,,std" and ,,::" do?
Also why is there ,,!" in the parenthases?
0
I'm new so I don't really understand what std and namespace is. Is namespace like a library similar like you ,,import (Library name)" in Python 3?
0
oh god I still don't get it lol