.NETGURU
Bit of an inheritance quandary
Messages   Related Types
This message was discovered on ASPFriends.com 'ngfx-patterns' list.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.

Ryan Trudelle-Schwarz (VIP)
-- Copied from [aspngarchitecture] to [ngfx-patterns] by Charles M. Carroll <Click here to reveal e-mail address> --Have the following base classes: RandomWeighted    Methods:        Overrided Render    Variables:        intLimit    Properties:        Limit WeightedItem    Variables        intWeight    Properties        WeightI want to inherit from both for one class.What's the standard practice now that multiple inheritances aren'tallowed?I can't think of an easy way to do this without it being very messy andwasteful.These two base classes are inherited independently in other classes,it's only this one class I'm creating that needs the functionality fromboth.Thanks, Ryan
Reply to this message...
 
    
Scott Watermasysk (VIP)
I am a relative newcomer to OOP, but what about:

public class x: RandomWeighted
{}
public class useable : x
{
}

-Scott

-----Original Message-----
From: Ryan Trudelle-Schwarz [mailto:Click here to reveal e-mail address]
Sent: Monday, January 07, 2002 4:56 PM
To: ngfx-patterns
Subject: [ngfx-patterns] Bit of an inheritance quandary

| [ngfx-patterns] member Click here to reveal e-mail address = YOUR ID
| http://www.aspfriends.com/aspfriends/ngfx-patterns.asp = JOIN/QUIT
-- Copied from [aspngarchitecture] to [ngfx-patterns] by Charles M. Carroll
<Click here to reveal e-mail address> --

Have the following base classes:

RandomWeighted
    Methods:
        Overrided Render
    Variables:
        intLimit
    Properties:
        Limit

WeightedItem
    Variables
        intWeight
    Properties
        Weight

I want to inherit from both for one class.

What's the standard practice now that multiple inheritances aren't
allowed?

I can't think of an easy way to do this without it being very messy and
wasteful.

These two base classes are inherited independently in other classes,
it's only this one class I'm creating that needs the functionality from
both.

Thanks, Ryan

Reply to this message...
 
    
Ryan Trudelle-Schwarz (VIP)
Problem is that other classes need to inherit from these base classes
separately. Only the one needs to have the functionality of both.

-----Original Message-----
From: Scott Watermasysk [mailto:Click here to reveal e-mail address]

Sent: Tuesday, January 08, 2002 8:57 AM
To: ngfx-patterns
Subject: [ngfx-patterns] RE: Bit of an inheritance quandary

| [ngfx-patterns] member Click here to reveal e-mail address = YOUR ID
| http://www.aspfriends.com/aspfriends/ngfx-patterns.asp = JOIN/QUIT
I am a relative newcomer to OOP, but what about:

public class x: RandomWeighted
{}
public class useable : x
{
}

-Scott

-----Original Message-----
From: Ryan Trudelle-Schwarz [mailto:Click here to reveal e-mail address]
Sent: Monday, January 07, 2002 4:56 PM
To: ngfx-patterns
Subject: [ngfx-patterns] Bit of an inheritance quandary

| [ngfx-patterns] member Click here to reveal e-mail address = YOUR
ID
| http://www.aspfriends.com/aspfriends/ngfx-patterns.asp = JOIN/QUIT
-- Copied from [aspngarchitecture] to [ngfx-patterns] by Charles M.
Carroll
<Click here to reveal e-mail address> --

Have the following base classes:

RandomWeighted
    Methods:
        Overrided Render
    Variables:
        intLimit
    Properties:
        Limit

WeightedItem
    Variables
        intWeight
    Properties
        Weight

I want to inherit from both for one class.

What's the standard practice now that multiple inheritances aren't
allowed?

I can't think of an easy way to do this without it being very messy and
wasteful.

These two base classes are inherited independently in other classes,
it's only this one class I'm creating that needs the functionality from
both.

Thanks, Ryan

Reply to this message...
 
    
bryan costanich
The 'standard practice' so to speak when multiple inheritance is needed
is to implement an interface, but obviously that has it's own drawbacks
as well. You can implement from as many interfaces as you would like.

In the sdk:
ms-help://MS.NETFrameworkSDK/vbls7/html/vblrfVBSpec4_2_2.htm

-----Original Message-----
From: Ryan Trudelle-Schwarz [mailto:Click here to reveal e-mail address]=20
Sent: Tuesday, January 08, 2002 9:14 AM
To: ngfx-patterns
Subject: [ngfx-patterns] RE: Bit of an inheritance quandary

| [ngfx-patterns] member Click here to reveal e-mail address =3D YOUR ID
| http://www.aspfriends.com/aspfriends/ngfx-patterns.asp =3D JOIN/QUIT
Problem is that other classes need to inherit from these base classes
separately. Only the one needs to have the functionality of both.

-----Original Message-----
From: Scott Watermasysk [mailto:Click here to reveal e-mail address]

Sent: Tuesday, January 08, 2002 8:57 AM
To: ngfx-patterns
Subject: [ngfx-patterns] RE: Bit of an inheritance quandary

| [ngfx-patterns] member Click here to reveal e-mail address =3D YOUR ID
| http://www.aspfriends.com/aspfriends/ngfx-patterns.asp =3D JOIN/QUIT
I am a relative newcomer to OOP, but what about:

public class x: RandomWeighted
{}
public class useable : x
{
}

-Scott

-----Original Message-----
From: Ryan Trudelle-Schwarz [mailto:Click here to reveal e-mail address]
Sent: Monday, January 07, 2002 4:56 PM
To: ngfx-patterns
Subject: [ngfx-patterns] Bit of an inheritance quandary

| [ngfx-patterns] member Click here to reveal e-mail address =3D =
YOUR
ID
| http://www.aspfriends.com/aspfriends/ngfx-patterns.asp =3D JOIN/QUIT
-- Copied from [aspngarchitecture] to [ngfx-patterns] by Charles M.
Carroll
<Click here to reveal e-mail address> --

Have the following base classes:

RandomWeighted
    Methods:
        Overrided Render
    Variables:
        intLimit
    Properties:
        Limit

WeightedItem
    Variables
        intWeight
    Properties
        Weight

I want to inherit from both for one class.

What's the standard practice now that multiple inheritances aren't
allowed?

I can't think of an easy way to do this without it being very messy and
wasteful.

These two base classes are inherited independently in other classes,
it's only this one class I'm creating that needs the functionality from
both.

Thanks, Ryan

Reply to this message...
 
 




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification