protected modifier for a class

  • Thread starter Thread starter Dan Cimpoiesu
  • Start date Start date
D

Dan Cimpoiesu

Hello

What does mean when a protected modifier is apllied to a class.

I want to inherit a protected class defined in another class, I saw that the
microsoft programmers achieved that.
But I cannot ( ex.I want to inherit the protected abstract class
CollectionForm that is defined in the CollectionEditor class but I don't
achieve this). Any suggestions?

Regards
Dan Cimpoiesu
 
HI,

If you are interested in inhering from an abstract class,

use the following guidelines.

public class MyCar : Car
{
public override void GoForward(int I)
{
// Specific implementation of this method would go here
}
public override int CheckSpeed()
{
// Implementation for this method goes here
}
public override string Color
{
get
{
// Both the getter and the setter must be implemented
}
set
{
// Setter implementation goes here
}
}
}


Also, are you referening the target library
(i.e. using System.xxx)
 
Thanks for the answer, but I was asking something else.
I found the answer myself though.

I figure the following situation

Existing class

public class A
{
protected class InnerA
{
}
}

and I want to inherit the class InnerA

I found the following solution

public class B : A
{
protected class InnerB : A.InnerA
{
}
}

Note. the modifier for the class InnerB must be weaker than the modifier for
B that means private or protected.

So the conclusion is that a class marked as protected and that is declared
in another class, can be inherited only in a inherited class of the
containing class. :))
Anyway it seems that the Intellisense feature of the VS IDE does not know
this trick.

Regards
Dan Cimpoiesu
 
Back
Top