about c++

4 views
Skip to first unread message

i'm_just_a_kid

unread,
Jun 26, 2008, 3:26:28 AM6/26/08
to Google Code for Educators
i started turbo c++ i was trying to figure out sone questions i
thought this will be the best place
1.whats the use and the meaning of "using namespace std"
2.whats the use of using return 0

Manjunath Bhat

unread,
Jun 26, 2008, 4:07:51 AM6/26/08
to Google-Code-...@googlegroups.com
return 0 indicates that the main() function executed without error. If there is an exception or some other error (such as trying to input from a stream in the fail state), a 1 is returned, indicating that the program finished, but with errors.

I think in C you can declare main() as void main(), but in C++ you must declare main() as an int returning function.

 

Thanks & Regards
Manjunath Bhat

TommyJ

unread,
Aug 8, 2008, 2:13:16 AM8/8/08
to Google Code for Educators
1. When you write "using namespace std", you are telling the program
to include the standard library. This way instead of typing "std::cout
<< "hi" << std::endl;" you can just type "cout << "hi" << endl;".

2. returning 0 ends the function. any function that is not labeled
void, needs to return something. The main() method in c++ generally is
written "int main()" notice the int at the beginning, this is the
return type (what the function need to return). You could also say
"bool main()" and just return a boolean value (true or false).

Feel free email me with any questions you have!

-Tom
Reply all
Reply to author
Forward
0 new messages