+ 1
Is Main function an integer variable?
as i mentioned in title i do not exactly understand that. main function is ALL statements itself. why this is an integer? why it must describe as any variable?
6 Réponses
+ 6
is not a variable, is a function.
The int statment you mean, is the one that call the type of return in a function:
Int main(string args[]){
return 0; //THIS IS A INT, BEING RETURNED
}
+ 5
I will recommend to re-do the course, if not taken yet.
Function is a block of code you can call and do something.
Variable is a space in memory which can store a value.
They follow this structure mostly:
function dosomething (){
//do something
}
var name = value;
+ 4
They can return ANY type, including your own defined classes!
And void is to no return type functions.
+ 1
ok i have quest for you.
could all functions take all types ( int, float, string etc.)
or they have special categoriztion from variables ?
0
okay. i think i have to get that;
what is the function and variable in c++
0
As a previous poster mentioned, int is the value being returned. If you say "int main(){stuff}" at the beginning then you will need to return an integer in the end of your main function. Its worth noting that you don't HAVE to return anything if you set it up differently. Instead say "void main(){stuff}" and you no longer need the return.