Eric Fowler

Eric Fowler

  • NA
  • 1
  • 0

How to prevent derived class clts from using base class fxn

Mar 21 2013 12:10 PM

I have a base and derived class, as follows:

class BaseClass
{
public BaseClass(string str){ ... do stuff with str ...};
};

class DerivedClass : BaseClass
{
public Foo(string str, IntPtr ptr) { ... do stuff with str and ptr ....}
};

// Other classes can derive from BaseClass ....


Client code looks like this:

DerivedClass dc = new DerivedClass();
dc.Foo("Hello");  // <--- note no IntPtr being passed. 

In these cases, the base class function is being called. 

What I want is a compile time error. 

How to get one?




Answers (1)