Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 26th, 2004, 01:44 AM
Registered User
 
Join Date: Mar 2004
Location: Hoquiam, WA, USA.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default c# inheritance

Suppose you have the following

public class Car
{
  public Car (int IgnitionShape, Engine new Engine)
  {
    //code here
  }
}

How do you code the FlyingCar such that it inherits from the Car Class

For one parameter it's
public class FlyingCar : Car
{
  public FlyingCar(int IgnitionShape : base (IgnitionShape)
  {

but for two parameters the following doesn't work

public class FlyingCar : Car
{
  public FlyingCar(int IgnitionShape, Engine newEngine) : base (int IgnitionShape, Engine newEngine)
  {
  \\code here
  }
}

Any thoughts?
Reply With Quote
  #2 (permalink)  
Old March 26th, 2004, 04:25 AM
Imar's Avatar
Wrox Author
Points: 72,045, Level: 100
Points: 72,045, Level: 100 Points: 72,045, Level: 100 Points: 72,045, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,083
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Hi there,

You shouldn't pass the datatypes to the base class's constructor:
Code:
public class FlyingCar : Car
{
  public FlyingCar(int IgnitionShape, Engine newEngine) : base (IgnitionShape, newEngine)
  {
    // code here
  }
}
Cheers,

Imar

---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Reply With Quote
  #3 (permalink)  
Old March 26th, 2004, 01:47 PM
Registered User
 
Join Date: Mar 2004
Location: Hoquiam, WA, USA.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Imar.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Inheritance magagulad Visual Basic 2005 Basics 1 May 12th, 2008 07:51 AM
Inheritance michaelcode ASP.NET 2.0 Basics 5 September 26th, 2006 01:40 PM
Inheritance abhi_bth ASP.NET 1.0 and 1.1 Basics 0 September 23rd, 2006 10:03 AM
Need help with inheritance filip BOOK: Professional JavaScript for Web Developers ISBN: 978-0-7645-7908-0 1 August 25th, 2006 09:38 PM



All times are GMT -4. The time now is 04:46 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.