protected cantoverride modifier 
Author Message
 protected cantoverride modifier

Hi,

I've created an abstract class that is derived from a UserControl and has a
method called GetHTML() which I don't want the derived classed to be able to
override.  This method must be run from the abstract class.

There's no modifier (that I can see) that allows you to seal the method....
There is the "sealed" modifier for methods that have been derived and is not
allowed to be overridden by a derived class.... but what if it's also the
first?  This is the first and final implemenation of this method allowed.

Compiler error message:
'GetHTML()' cannot be sealed because it is not an override

Am i missing something here?

TIA.

kk



Thu, 30 Dec 2004 20:00:26 GMT  
 protected cantoverride modifier
Hi,

What about private or internal ???


Quote:
> Hi,

> I've created an abstract class that is derived from a UserControl and has
a
> method called GetHTML() which I don't want the derived classed to be able
to
> override.  This method must be run from the abstract class.

> There's no modifier (that I can see) that allows you to seal the
method....
> There is the "sealed" modifier for methods that have been derived and is
not
> allowed to be overridden by a derived class.... but what if it's also the
> first?  This is the first and final implemenation of this method allowed.

> Compiler error message:
> 'GetHTML()' cannot be sealed because it is not an override

> Am i missing something here?

> TIA.

> kk



Thu, 30 Dec 2004 21:01:45 GMT  
 protected cantoverride modifier
Ha ha.... I was looking into it too deaply.  Of course protected by itself
does it.

:)

Thanks.


Quote:
> Hi,

> What about private or internal ???



> > Hi,

> > I've created an abstract class that is derived from a UserControl and
has
> a
> > method called GetHTML() which I don't want the derived classed to be
able
> to
> > override.  This method must be run from the abstract class.

> > There's no modifier (that I can see) that allows you to seal the
> method....
> > There is the "sealed" modifier for methods that have been derived and is
> not
> > allowed to be overridden by a derived class.... but what if it's also
the
> > first?  This is the first and final implemenation of this method
allowed.

> > Compiler error message:
> > 'GetHTML()' cannot be sealed because it is not an override

> > Am i missing something here?

> > TIA.

> > kk



Thu, 30 Dec 2004 20:12:00 GMT  
 protected cantoverride modifier
Actually, the correct answer is that if you do not mark the
method as "virtual", then subclasses cannot "override" it.

I'm not sure, but I think that they may be able to "new" it,
though.

-c


Quote:
> Ha ha.... I was looking into it too deaply.  Of course protected by itself
> does it.

> :)

> Thanks.



> > Hi,

> > What about private or internal ???



> > > Hi,

> > > I've created an abstract class that is derived from a UserControl and
> has
> > a
> > > method called GetHTML() which I don't want the derived classed to be
> able
> > to
> > > override.  This method must be run from the abstract class.

> > > There's no modifier (that I can see) that allows you to seal the
> > method....
> > > There is the "sealed" modifier for methods that have been derived and
is
> > not
> > > allowed to be overridden by a derived class.... but what if it's also
> the
> > > first?  This is the first and final implemenation of this method
> allowed.

> > > Compiler error message:
> > > 'GetHTML()' cannot be sealed because it is not an override

> > > Am i missing something here?

> > > TIA.

> > > kk



Thu, 30 Dec 2004 23:37:41 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. protected internal & protected

2. Main() method of default access modifier ??

3. compiler error using volatile modifier!

4. Proper access modifier(s) for dtors in MC++?

5. About Access-Modifier in the Main() method

6. 'h' modifier in printf

7. VOLATILE modifier (Explanation anybody?)

8. using the windows key as a modifier

9. access modifiers on accessor declarators

10. missing ; before modifier

11. EXE MODIFIER , DOS HACKING

12. problem with type modifiers

 

 
Powered by phpBB® Forum Software