Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 30th, 2004, 06:26 AM
Friend of Wrox
 
Join Date: Jul 2004
Posts: 623
Thanks: 0
Thanked 1 Time in 1 Post
Default multiple inheritance in C#

Hi experts,
Suppose I wanna design a program for a faculty,I should consider students,employees,...
but here someone could be students and employee together...
I think here I need multiple inheritance but there is no multiple inheritance in C# so I designed it like this,
an interface for students,a class for students,
an interface for employees,a class for employees,
another class that implements student interface and employee interface,(for those are student and employee)
I dont know whether there are better ways for this,
Thanks in advance.

_____________________________
Mehdi.
software engineering student.
Looking for a good job for summer 2005.
__________________
_____________
<font color=\"teal\"><font size=\"1\"><b>Mehdi.
software student.</b></font id=\"size1\"></font id=\"teal\">
 
Old November 30th, 2004, 06:03 PM
Kep Kep is offline
Authorized User
 
Join Date: Aug 2003
Posts: 79
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Interfaces are your only choice for multiple inheritance in C#.

Kep.
 
Old December 1st, 2004, 04:12 AM
Friend of Wrox
 
Join Date: Jul 2004
Posts: 623
Thanks: 0
Thanked 1 Time in 1 Post
Default

well,I know interfaces are used for declarations of some procedures or properties,if I dont use interfaces I can just write my implementations in classes ... can you clarify your meaning more?
I found another design,for example,
I can have an interface for students and a StudentClass implements StudentInterface and also an interface for employees and a EmployeeClass implements EmployeeInterface,
then I derive a class(StudentEmployee) from StudentClass and implement EmployeeInterface.I think this could be a better approach.

_____________________________
Mehdi.
software engineering student.
Looking for a good job for summer 2005.
 
Old December 2nd, 2004, 06:01 AM
Friend of Wrox
 
Join Date: Jul 2004
Posts: 623
Thanks: 0
Thanked 1 Time in 1 Post
Default

I think I got my answer,we use interfaces for reducing code-using and also for different implementations,
(when you want to write a program for a teacher just knows PASCAL!,about two hours we were struggling to teach our dear teacher what could be an interface!what could be an inheritance!what could be a ....)

_____________________________
Mehdi.
software engineering student.
Looking for a good job for summer 2005.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Why C# is not supporting Multiple Inheritance? ramk_1978 C# 5 April 26th, 2006 08:05 AM
Multiple inheritance with VTable subhash_w C# 1 August 2nd, 2005 05:23 AM
Multiple inheritance with VTable subhash_w Visual C++ 2005 1 July 31st, 2005 02:41 PM
Multiple inheritance with VTable subhash_w C++ Programming 0 July 31st, 2005 04:40 AM
Multiple inheritance with VTable subhash_w BOOK: Professional C++ 0 July 31st, 2005 04:35 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.