Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Abstract Static Functions

Status
Not open for further replies.

ThankGodItsFriday

Programmer
May 12, 2005
11
SE
Declaring a member function as abstract static generates a compile error, "A static member cannot be marked as override, virtual, or abstract".

Why is it a bad thing to declare a function like this?
 
Hope this will help you:

Abstract method declaration provides no actual implementation, there is no method body; the method declaration simply ends with a semicolon and there are no braces ({ }) following the signature. For example:

public abstract void MyMethod();

The implementation is provided by an overriding method, which is a member of a non-abstract class.

You cannot override a non-virtual or static method. The overridden base method must be virtual, abstract, or override.

Reference MSDN:
 
This doesn't quite answer my question.

A member function requires that you instansiate an object before using it. If the method is derived from a baseclass it can be overridden from that class, but the same isn't true if the function is static.

I've got a baseclass vith a number of functions that the subclasses must implement themself, but they should be static.
I'd like to be able to declare in the baseclass that the subclasses must implement the static functions but I'm not allowed to do this, and I dont understand why.

It could be that I'm thinking completely wrong though... :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top