TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
James
NA
2
0
Can't figure out how to share some code
May 9 2006 5:07 PM
I have some code which I want to pull out of a class so I can share it with other classes. I can't figure out how to do it with the restrictions that I have. Here is my situation.
I have a class B which inherits from a 3rd party base class A. The restriction is that I can only have one class in my project which inherits from base class A due to the way the larger system we are working on is design.
public B : A
{
private void MakeLunch(int numLunches)
{
for (int i=0; i < numLunches; i++)
{
.... // get bread, ham, etc.
.... // put mayo on bread, slice ham, etc.
base.MakeSandwich(bread, ham, ...); // MakeSandwich() is protected
}
}
}
Originally, I tried taking out MakeLunch() into its own class (class C) and deriving from class A so I can get the MakeSandwich() method, but I found out that only one class in my project can derive from class A. (create class C in another project is not an option)
I then tried to pass a reference to class B when I create class C but the MakeSandwich() method from class A is protected.
Anyone know of a way for me to pull out my MakeLunch() method into its own class?
Reply
Answers (
0
)
Speech sdk5.1
C#-based apps, will it run under windows 95 and 98se