Please Reply

hi my name is stackey maria i am a student of software engn. m learning from NIIT.
Please Can anybody tell me that how to Run a Program without (Main) in C++
i tried to find on Google but haven't get a good answer ! :(
main is the function that tells the compiler where the program starts, you can't run a program without it. (I think)
IMO,

if your "program" doesn't have a main function;
1. it's missing main, add it, compile it, run it.
2. it's not a program. so figure what it is, library, dll, what? act accordingly.

what exactly you have in hand?
You lost the bet, get over it. A kind of main() is mandatory. There's _tmain() and WinMain() but they're Windows-only.
but i heard that it can run without
Main()

in C# it runs without
Main()
closed account (z05DSL3A)
Contrary to popular belief C++ does not always require a main function, however the likelihood of you using a system the does not require it is small.

There are two kinds of implementation of the C++ standard; hosted and freestanding. A freestanding implementation is one that is designed for programs that are executed without the benefit of an operating system. For free standing implementation the requirement for a main function is implementation defined.

the standard wrote:
A program shall contain a global function called main, which is the designated start of the program. It is implementation-defined whether a program in a freestanding environment is required to define a main function. [Note: in a freestanding environment, start-up and termination is implementation-defined; startup contains the execution of constructors for objects of namespace scope with static storage duration; termination contains the execution of destructors for objects with static storage duration. ]


---
Edit:
in C# it runs without
Main()

Are you sure about that? The CLR has to make a call to an entry point and I'm fairly certain it has to be called Main. Even if it does not have to be called main it there has to be an entry point and you may just as well call it Main.
Last edited on
Hey Stackey Mariam, is there NIIT in your country? And what course are you really studying???
Topic archived. No new replies allowed.