Relevance of 'public' constructor in abstract class.

Posted by Amby on Stack Overflow See other posts from Stack Overflow or by Amby
Published on 2010-04-30T05:12:11Z Indexed on 2010/04/30 5:57 UTC
Read the original article Hit count: 284

Filed under:
|
|
|

Is there any relevance of a 'public' constructor in an abstract class? I can not think of any possible way to use it, in that case shouldn't it be treated as error by compiler (C#, not sure if other languages allow that).

Sample Code:

internal abstract class Vehicle
{
    public Vehicle()
    {            
    }
}

The C# compiler allows this code to compile, while there is no way i can call this contructor from the outside world. It can be called from derived classes only. So shouldn't it allow 'protected' and 'private' modifiers only. Please comment.

© Stack Overflow or respective owner

Related posts about .NET

Related posts about c#