[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

Followup) Computers:Programming:Languages->"easy one"

Posted on 1999-11-01
4
Medium Priority
?
194 Views
Last Modified: 2010-04-01
In the locked question "easy one" under the group "Computers:Programming:Languages", somebody makes the point that you can NOT call "main()" recursively in C++ (only in C) and another contests this point.  

Calling "main()" recursively under SunPro CC 4.2 and 5.0 fails, but succeeds under g++ 2.8.1.  It supposedly works in Visual C++.

I tried to find a reference to "main()" and "recursive" in Stroustrup 3rd Edition and in Schildt 3rd Edition, and had no luck.

I do not have a copy of the standard.  Just wondering if anyone knew if the standard prohbits the recursive calling of main()?
0
Comment
Question by:barryc
  • 3
4 Comments
 
LVL 22

Expert Comment

by:nietod
ID: 2175807
I'll look into it.  But I don't remember any restriction against it.
0
 
LVL 22

Accepted Solution

by:
nietod earned 200 total points
ID: 2175811
Wow.  I didn't remember it, but i definitely read the section that it came from.  Not it is not allowed to be called.


The function main() shall not be called from within a program. The linkage (3.5) of main() is implementation-defined. The address of main() shall not be taken and main() shall not be declared inline or static. The name main is not otherwise reserved. [ Example: member functions, classes, and enumerations can be called main, as can entities in other namespaces. ]


0
 
LVL 22

Expert Comment

by:nietod
ID: 2175851
>> I do not have a copy of the standard.

The copy I use is at

http://www.cygnus.com/misc/wp/

This is the final _draft_ version.  The final version is not available for free, but can be downloaded for about $15.  (a printed copy is like $300).  However the draft standard is extremely close to the final standard, so I don't think its worth the money.

Of course, this will probably cost me a lot of points...   : - )
0
 

Author Comment

by:barryc
ID: 2175859
Thanks nietod!
0

Featured Post

Learn to develop an Android App

Want to increase your earning potential in 2018? Pad your resume with app building experience. Learn how with this hands-on course.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Article by: evilrix
Looking for a way to avoid searching through large data sets for data that doesn't exist? A Bloom Filter might be what you need. This data structure is a probabilistic filter that allows you to avoid unnecessary searches when you know the data defin…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

591 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question