Can main() be overridden

Questions by avijit_sinha

Showing Answers 1 - 10 of 10 Answers

hiresh chandrakar

  • Feb 28th, 2006
 

no,main() can not be overridden.

  Was this answer useful?  Yes

swarn kant

  • Mar 13th, 2006
 

No, main cannot be overridden.

  Was this answer useful?  Yes

paulson paul chambakottukudyil

  • Apr 12th, 2006
 

In any application, there can be only one main function. In c++, main is not a member of any class. There is no chance of overriding.

  Was this answer useful?  Yes

Venkat Rama Krishna

  • Jul 11th, 2006
 

HiSee the following c++ program segment. I have written main as the member of "abc" class.. Is this not overriding of main() ??? Pls clarify me on this........#include "stdio.h"#include "stdlib.h"#include "iostream"using namespace std;class abc{ public : int main() { cout<<" Its main function of Claass member"<

  Was this answer useful?  Yes

Arti Kulkarni

  • Jul 14th, 2006
 

Hi,

In one *.cpp file we can declare only one main() ie we cant' write more than 1 main functions in one program file. it will give an error.As main() [from which the program execution begins] is not a member function of any class..so there is no question of overloading or overriding of the function.

Yes, but in any userdefined class we can declare main() as a class member function and also can overload or override that member function.

  Was this answer useful?  Yes

jay

  • Sep 17th, 2006
 

main (as a method of some class) CAN be OVERRIDEN, it can't be OVERLOADED though.Overriding means providing in a subclass a different implementation of a method defined in it's superclass.You probably ment overloading which is providing different implementations for a function, based on it's argument list .Anyways, you can't overload entry point main cause the linker won't like this and you'll have a name conflict ( declaration of C function `int main(...)' conflicts with previous declaration int main(...)"

  Was this answer useful?  Yes

Me

  • Oct 18th, 2006
 

I believe that you may be able to override main (I haven't actually tried though..). I don't see why you'd get any linker errors if you re-def the entry point as a linker switch...Thoughts?Anybody have time to try? =D

  Was this answer useful?  Yes

vishwa

  • Nov 16th, 2006
 

Yes,
 
Mail can be overriden, but not overlaoded

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions