+ 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?

13th Feb 2017, 2:57 AM
Arif Soylu
Arif Soylu - avatar
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 }
13th Feb 2017, 3:01 AM
Nahuel
Nahuel - avatar
+ 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;
13th Feb 2017, 3:08 AM
Nahuel
Nahuel - avatar
+ 4
They can return ANY type, including your own defined classes! And void is to no return type functions.
13th Feb 2017, 3:30 AM
Nahuel
Nahuel - avatar
+ 1
ok i have quest for you. could all functions take all types ( int, float, string etc.) or they have special categoriztion from variables ?
13th Feb 2017, 3:12 AM
Arif Soylu
Arif Soylu - avatar
0
okay. i think i have to get that; what is the function and variable in c++
13th Feb 2017, 3:03 AM
Arif Soylu
Arif Soylu - avatar
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.
13th Feb 2017, 3:24 AM
Sam