arrow_upward

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Explaining your first program! [C++]
#4
the function typing is very important, if you do void main() you do not need to return a string. but if you do int main() an integer is must to return from the function which might be a problem if new learners do not understand this. if you read carefully i mentioned in my previous post

there is a particular meaning of ">>" and "<<" in the language, ">>" is used for output and "<<" is used fir input, so it's better to be clear about this
(10-03-2015, 06:16 PM)Conan Wrote:
(10-01-2015, 09:59 AM)Rishabh-Jain Wrote: it is a great effort by you.  i appreciate it very much,
i would like to add something in your tutorial.
1st) I think you should include the full header file as this is a beginners  level tutorial
#include <iostream.h>

2nd) use the main function as void main() instead of int main() because the users might get error if they forgot to return an int. or even worse if they don't realize that they only have to return int. for a function defined as int type

3rd) Please include the importance of  "<<" in cout << "Hello, anon!" << endl; that why it "<<" not ">>"

OSM WORK

Best Regard

int main is what is most used in C++ examples from what I have seen. I also use int main since I need to return 1 when there are errors. (or exit(-1))

It's also common sense that if "<<" is the one in the example, then it is the correct one. And that ">>" would be a different one. Like how "and" and "end" sounds alike but is totally different.
lockThread Closed 


Messages In This Thread
Explaining your first program! [C++] - by paronte - 10-01-2015, 04:09 AM
RE: Explaining your first program! [C++] - by Rishabh Jain - 10-05-2015, 05:33 PM

Possibly Related Threads…
Thread
Author
Replies
Views
Last Post

person_pin_circle Users browsing this thread: 2 Guest(s)
Sponsors: VirMach - Host4Fun - CubeData - Evolution-Host - HostDare - Hyper Expert - Shadow Hosting - Bladenode - Hostlease - RackNerd - ReadyDedis - Limitless Hosting