dont know topic

can we set float main()
instead of void mani() or int main()?
and if we can why dont we do that???
can we set float main()

No.

instead of void mani()

That's also not C++. I'll make it clear: void main() is wrong. Wrong wrong wrong.

int main()
This one is acceptable. In C++, main returns an int, always always always.

why dont we do that???

The C++ standard - that is, the big document that defines what C++ is - makes it clear that main returns an int. That's correct C++. Anything else is not. A good C++ compiler will refuse to compiler anything else, because it's not C++.

This has the effect that the function that the operating system ultimately uses to call main (your code starts at main, but there are some other things that happen first and then main is called) expects main to return an int. If main returns something else, you're asking for trouble.
Last edited on
hey man i studied sumita arora and in the whole book there is no mention that void main()
is not in c++ just check yourself...
Why would I read a book I know to be bad when I could just look in the document that actually defines C++? The document that actually defines what C++ is makes it clear that void main() is wrong. It is currently ISO/IEC 14882:2011 (the 2011 version). There is also a 2003 version and a 1998 version. They all agree that void main() is not C++.

It doesn't matter what some other book says. There is one document that defines what C++ is. It has gone through a few different versions, but each version makes it very clear that void main() is not C++.
Last edited on
ok
guess this isnt my site....
i m leaving this site forever bye...
Please do.
Topic archived. No new replies allowed.