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 March 26th, 2004, 01:44 AM
Registered User
 
Join Date: Mar 2004
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?
 
Old March 26th, 2004, 04:25 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 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.
 
Old March 26th, 2004, 01:47 PM
Registered User
 
Join Date: Mar 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Imar.





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





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