answersLogoWhite

0


Best Answer

Perhaps this question is misplaced: the category is for C#, while the question is for C language.

The short answer for either language is NO. Main() is not overridable, and it must be implemented to start with.

For C# (I assume it was a typo in the question), the question is why one wants to override a method. Notice that Main() is a static method, and any static method in C# cannot be overridden. In fact, any static member (of a class) cannot be overridden.

The responsibility what Main should do is to serve as the entry point of the program. Although one may argue that it also serves the exiting point of the program, this is not the point. I strongly recommend only writing codes in Main() for:

  • Any initialization to the application (or delegate to other objects),
  • Any tear down to the application (or delegate to other objects),
  • Delegate the core application logic to another method
  • Validating the commandline arguments (or delegate to other objects)

Because the above are SPECIALIZED for a particular application, there is nothing to be inherited from, and thus nothing to override (from inheritance)

User Avatar

Wiki User

13y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Is it possible to override the Main method in C?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How do you override functions in c?

Not possible in C, only in C++


How can override the precedence define by c language?

Not possible; use (brackets) instead.


How is hiding method different from overriding method in c sharp?

Hiding means a class cannot see the definition. Overriding implies that a class must see that to "override"


Use the Multiple Main method C?

There are no methods in C, and you should have only one main function.Methods are associated with a specific class, and there are no classes in c.


Can a C program be written without main METHOD?

Every program requires an entry point. Main() provides the entry point in C.


Can you write multiple Mains in C-Sharp programming?

No. There can only be one main method, however you can declare new methods, and call them from the main method. Or you can use multi-threading, to simulate having multiple main methods.


Is overriding a dynamic polymorphism in c plus plus or not?

In C++, overriding and function, method, or operator is a different thing than (dynamic) polymorphism, so overriding a polymorphic method is almost entirely possible.


How can the General Assembly override the govenor's veto?

reopen the bill


What is the Difference between override and new keyword in C?

An override is the specialisation of a virtual function. The new keyword instantiates an instance of an object in dynamic memory and returns a reference to that object (or null if the object could be instantiated). Both are used in C++, but not C.


How do you write a programm in c plus plus without using function main?

I don't think its possible. Every C++ program must at least have the main function.


Can you declare a method within a method in c or c plus plus?

C: there are no methods in C. C++: no.


Which method is called first of all other methods when any application executed in c sharp?

static method Main() of the start object/class.There are 4 different signatures of Main():static void Main();static int Man();static void Main(string[] args);static int Main(string[] args);The starting object/class can have only one of them. Other classes or objects may have Main() method as well. (But why would be the question, Main() is NOT a good OO method name anyway. Method name should be a verb or start with a verb)