Restricting Inheriting Scope of a class

  • Thread starter Thread starter Rahul Arora
  • Start date Start date
R

Rahul Arora

Hi All,

I am designing some class for my DataLayer. The scenario is i have
three classess Class1,Class2,Class3. Class1 is base class for class2
and class3. It's a DLL project. What my problem is i want only class2
and class3 to be viewed as the part of the DLL and Class1 should be
hidden. Class1 is used only for deriving Class2 and Class3 in my DLL.
Once i compile the DLL and include in my application, it shows all
three classes there but i dont want class1 to appear there. Is this
possible ??? if yes..plz. suggest the way it can be implemented. I dont
want to create any other DLL for my Base class Class1. Basically i want
the scope of Class1 to be restricted to it's assembly only and Class2
and Class2 should be available to other assembilies....Please help...

Rahul Arora
 
Rahul Arora said:
Hi All,

I am designing some class for my DataLayer. The scenario is i have
three classess Class1,Class2,Class3. Class1 is base class for class2
and class3. It's a DLL project. What my problem is i want only class2
and class3 to be viewed as the part of the DLL and Class1 should be
hidden. Class1 is used only for deriving Class2 and Class3 in my DLL.
Once i compile the DLL and include in my application, it shows all
three classes there but i dont want class1 to appear there. Is this
possible ??? if yes..plz. suggest the way it can be implemented. I dont
want to create any other DLL for my Base class Class1. Basically i want
the scope of Class1 to be restricted to it's assembly only and Class2
and Class2 should be available to other assembilies....Please help...

You can't do it (despite what other postings might say).

You cannot have a base class less accessible than the derived class. i.e.
there is no possibility of inheritance form implementation only as in C++.

What you CAN do is make all the Class1 methods internal so that they can
only be called by your classes.
 
Back
Top