Why can't we use void main insted of int main as taught in our school | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Why can't we use void main insted of int main as taught in our school

5th Oct 2016, 1:36 AM
Vibhu
5 Answers
0
I don't know why your school teaches that, becaude void main doesn't work in the first place in c++ as the main function. What IDE does your school use? Are you sure your school is teaching c++ and not somrthing like java?
5th Oct 2016, 3:20 AM
dragonbro1015
dragonbro1015 - avatar
0
I think that may be Java
5th Oct 2016, 5:53 AM
Rolex Scotch
Rolex Scotch - avatar
0
Even in our skl they use void main as in the beginning for easy programs the return function is not needed. So void main is sufficient for all beginner programs
5th Oct 2016, 6:38 AM
red watson
red watson - avatar
0
void main is applicable in both java nd c++. in java u hv to define it with a static variable where as it is not the same in c++. Its like in java :- "public static void main" were as in c++ its just void main. I hv been usong bth of them, java in school nd c++ in college now
5th Oct 2016, 8:32 AM
Abhinav Upadhyay
Abhinav Upadhyay - avatar
0
A lot of issues between IDE's. Some allow void, others do not. Void is typically meant for Java, but some IDE's that can run Java OR C++ have some crossing that causes confusion.
7th Oct 2016, 2:37 PM
Chese780 ~
Chese780 ~ - avatar