+ 2
Difference beetween void, int and bool?
I’m very new to c++, in fact I’ve never done any code before. I’m taking lessons on Udemy, but so far I dont know what these three are used for?
5 Respuestas
+ 8
I see you have started the C++ course here. These data types are also explained in the SL course as you proceed with it.
+ 4
Don't worry about void then. Worry about void when you get into functions.
int is a whole number.
int a = 263;
bool is either true or false!
(or 1 for true and 0 for false)
bool b = true;
bool c = 4 == 4; // true!
bool d = 1; // true!
+ 1
void - no type
int - a positive or negative integer, ex. 1, 5, -2
bool - an integer, 0 means false, 1 means true
+ 1
if you don't like to return any value then use void, if you would like return integer value then use int and if you like to return true/false value the use bool.
0
void returns Nothing, int returns integer and bool return Boolean value ( true/false)